Continue fold-2 (after 374e97b): migrate the remaining Family-1 str/slice
global + literal + index + call-arg group from bespoke build+run C twins to
test/lang @test, retiring each twin in the same commit. Runtime coverage MOVES
from $(TESTS) to test-lang (T1 runs+asserts via `ww test`) + test-lang-byteid
(T2 keeps cs==ww .s byte-id); coverage is preserved, the $(TESTS) headline
drops 9 (434->425). All asserts are primitive int/u8/bool comparisons (no
fmt/strconv in the assert path); the slice-store/index rows reset the global
each fn and sum ADJACENT elements so a dropped/mis-strided/over-wide word FAILS.
989_globslicefield_run.c -> glob_slice_field_test.ww (slice field of a global struct: g.f=<slice> stores full 24B header; len/cap/non-zero-offset + str/scalar controls)
989_globstrslice_run.c -> glob_str_slice_arg_test.ww (global str sliced with default hi passed as call arg loads its len word; explicit-hi control)
989_trystr_run.c -> try_str_unwrap_test.ww (`!` unwrap of str-success tagged union shuffles the str header for ident-source/error-first/success-first)
797_len_strglobal_run.c -> len_str_global_test.ww (len(str-global) loads .len via name(SB); local-str control)
801_litstr_pseudo_run.c -> lit_str_pseudo_test.ww (string-literal .len/.ptr pseudo-field; empty/multibyte + arg-passthrough)
803_globalidx_run.c -> global_index_test.ww (global str/slice index read/addr-of/store/compound, esz 1/4; local regression pins)
903_tuple_elem_slice_len.c -> tuple_elem_slice_len_test.ww (len(t.N) of a slice/str tuple element loads .len at +8; 2/3-slice, str-slice both orders)
927_composite_call_arg_run.c-> composite_call_arg_test.ww (slice-returning CALL passed inline as a composite arg; canonical/letslice/two-call/middle/nested/scalar/tagged)
952_slicecopy_assign_run.c -> slice_copy_assign_test.ww (bulk slice-copy-assign `arr[lo:hi]=bs`, esz 1/4, field/via-ptr/local bases; reslice-read companion)
rd_reslice asserts the TRUE value 360 (the .c twin's want=104 was 360 & 0xFF,
an exit-code truncation). 723_composite_call_arg.c's comment repointed to the
new test/lang location. 802_lenidx_run.c is DEFERRED (it carries //ww:error
reject rows — needs a value-rows-only split + a slim reject carrier, a fold-3
pass). Bump LANGBYTEID_EXPECTED_MIN 22->31 to ratchet the new corpus floor.
59 lines
1.9 KiB
Plaintext
59 lines
1.9 KiB
Plaintext
// glob_slice_field_test — a SLICE field of a module-GLOBAL struct, assigned
|
|
// with `g.field = <slice>`, must store the full {ptr,len,cap} 24B header (not
|
|
// just {ptr}), migrated from test/wcc/989_globslicefield_run.c (F8-c1, #35).
|
|
// The wwstage single-dot global-struct field-assign gated the 3-word DX store
|
|
// on isstrtype ONLY, so a non-str slice field fell to the 1-word scalar store
|
|
// and silently DROPPED .len+.cap; the fix widens to isstrtype||isslicetype
|
|
// (align UP to cstage's TY_STR||TY_SLICE). cs==ww held byte-id-blind, so a
|
|
// behavioral @test is the net. A dropped .len/.cap reads back 0 (a fresh global
|
|
// is zeroed), so len()/.cap directly catch it; glob_off_len pins the non-zero
|
|
// field offset; the str/scalar rows are regression controls for the pre-existing
|
|
// arm and the 1-word store the slice arm must not steal.
|
|
|
|
package glob_slice_field_test;
|
|
|
|
type box1 = struct { sl: []i64 };
|
|
type box2 = struct { pad: i64, sl: []i64 };
|
|
type box3 = struct { name: str };
|
|
type box4 = struct { n: i64 };
|
|
|
|
let g1: box1;
|
|
let g2: box2;
|
|
let g3: box3;
|
|
let g4: box4;
|
|
|
|
@test fn glob_slice_len() void = {
|
|
let b: [4]i64 = [10, 11, 12, 13];
|
|
g1.sl = b[0:3];
|
|
assert(len(g1.sl): i32 == 3);
|
|
};
|
|
|
|
@test fn glob_slice_cap() void = {
|
|
let b: [4]i64 = [10, 11, 12, 13];
|
|
g1.sl = b[0:3];
|
|
assert(g1.sl.cap: i32 == 4);
|
|
};
|
|
|
|
@test fn glob_off_len() void = {
|
|
// slice field at a NON-ZERO field offset (pad@0, sl@8) pins the
|
|
// DX+foff+8 header store.
|
|
let b: [4]i64 = [10, 11, 12, 13];
|
|
g2.pad = 99;
|
|
g2.sl = b[0:2];
|
|
assert(g2.pad == 99);
|
|
assert(len(g2.sl): i32 == 2);
|
|
};
|
|
|
|
@test fn glob_str_len() void = {
|
|
// str field on a global struct — the pre-existing isstrtype arm; a
|
|
// regression pin that the widened gate keeps correct.
|
|
g3.name = "hello";
|
|
assert(len(g3.name): i32 == 5);
|
|
};
|
|
|
|
@test fn glob_scalar_n() void = {
|
|
// scalar field — the generic 1-word store the slice arm must not divert.
|
|
g4.n = 7;
|
|
assert(g4.n: i32 == 7);
|
|
};
|