Files
ww/test/lang/dotbase_addr_slice_runonly_test.ww
Hojun-Cho 50d1705100 test: migrate 949_dotbase_addr_slice to @test + byteid carve-out seam, retire C twin (fold-3)
#252/#253/#257 N_DOT-base addr-of-slice: 105 byteid=1 rows -> test/lang/dotbase_addr_slice_test.ww (primitive-only); 6 #254 run-only rows (4 chain_val_* + letcopy_dot_struct/letcopy_nest_struct, value-nested-struct frame divergence) -> dotbase_addr_slice_runonly_test.ww. New byteid-exclusion seam: LANGBYTEID_FILES filter-out %_runonly_test.ww (suffix convention; T1 value-runs both, T2 byteid skips runonly). byteid floor 54->55. Carve-out preserves the .c byteid field 1:1; all 105 byteid=1 rows verified cs==ww under the live sepwork gate.
2026-06-22 18:06:05 +09:00

70 lines
2.6 KiB
Plaintext

// dotbase_addr_slice_runonly_test — the VALUE-nested-struct cell of the
// array-field-base-address family (#253 chained-base / #270-3a aggregate
// index-base copy), migrated from test/wcc/949_dotbase_addr_slice_run.c.
//
// RUN-ONLY (#254): these rows exercise the SAME fixed cg_dotbase_addr /
// dotchainaddr helper as their sibling dotbase_addr_slice_test.ww rows and
// run CORRECTLY — the #253 segfault is gone for the value-container cell.
// But a value nested-struct instance trips TWO orthogonal pre-existing
// cs!=ww emission divergences, unrelated to the base-address fix:
// 1. bare-let zero-init policy — wwstage emits an extra `MOVQ $0,off(BP)`
// for a value nested-struct local that cstage does not;
// 2. global DATAW byte count — wwstage over-emits.
// Until #254 fixes both, the rule-10 T2 byte-id gate cannot apply to these
// rows. The `_runonly_test.ww` filename suffix is the EXPLICIT opt-out that
// excludes this file from LANGBYTEID_FILES (Makefile) — value-run only, no
// byteid. They stay as LIVE run-only value pins proving the segfault is gone
// for the value cell; never dropped. PRIMITIVE-only asserts (read back the
// value; a wrong base yields a wrong readback) — no fmt/strconv.
package dotbase_addr_slice_runonly_test;
type vinner = struct { m: [4]u8 };
type outv = struct { i: vinner };
// #253 chained VALUE-container arm (o.i.m — inner is a value nested struct).
@test fn chain_val_rd() void = {
let o: outv; o.i.m[1] = 66u8;
assert(o.i.m[1]: i32 == 66i32);
};
@test fn chain_val_addr() void = {
let o: outv; o.i.m[2] = 55u8;
let q: *u8 = &o.i.m[2];
assert((*q): i32 == 55i32);
};
@test fn chain_val_slice() void = {
let o: outv; o.i.m[1] = 66u8;
let s: []u8 = o.i.m[1:4];
assert(len(s): i32 == 3i32);
assert(s[0]: i32 == 66i32);
};
type vmid = struct { b: vinner };
type vtop = struct { a: vmid };
@test fn chain_deep_val() void = {
let o: vtop; o.a.b.m[1] = 66u8;
assert(o.a.b.m[1]: i32 == 66i32);
};
// #270-3a value-struct aggregate index-base let-init copy. Same #254
// carve-out as chain_val_* above (the .c marked these byteid=0 explicitly).
type lcinner = struct { a: u32, b: u32, c: u32 };
type lcbox = struct { arr: [3]lcinner };
@test fn letcopy_dot_struct() void = {
let x: lcbox;
let v: lcinner; v.a = 10u32; v.b = 20u32; v.c = 30u32;
x.arr[1] = v;
let c: lcinner = x.arr[1];
assert((c.a + c.b + c.c): i32 == 60i32);
};
@test fn letcopy_nest_struct() void = {
let a: [2][2]lcinner;
let v: lcinner; v.a = 11u32; v.b = 22u32; v.c = 33u32;
a[1][0] = v;
let c: lcinner = a[1][0];
assert((c.a + c.b + c.c): i32 == 66i32);
};