Files
ww/test/lang/nestfield_test.ww
Hojun-Cho 74cc35d488 test: migrate Fam4 static-init/DATA-emit value tests to @test (#30)
Continues the test-arch tower past Fam8-13. 11 module-level static-init
/ DATA-emit value drivers move from test/wcc/*_run.c into @test row-
tables under test/lang/; every classification empirically re-probed at
HEAD (refuting two stale worklist tags).

- value rows -> test/lang/*_test.ww (11 files)
- reject rows -> runww //ww:error carriers (3, dual-stage non-vacuous;
  947 const-divzero confirmed a both-stage compile-reject, not run-exit)
- 840_zeroinit, 944_array_zeroinit, 989_arrlit_tail_zero kept as byte-id
  .c pins (zero-over-dirtied-frame / DATAW-length is byte-id-blind to a
  runtime @test; #263), mutation-gated
- repoint two stale comment refs to deleted test names (719,
  989_structlocal_frame)

Migrated static-init @test ride the cs==ww T2 byte-id gate, preserving
DATA-emit byte-id. 2D global-struct array-field read (#137/#150)
confirmed cs==ww + correct at HEAD. Coverage parity verified row-by-row;
two-round reviewed. Floor ratchet follows.
2026-06-25 01:32:32 +09:00

39 lines
1.3 KiB
Plaintext

// nestfield_test — nested sub-8 composite struct field at natural offsets.
// Migrated from test/wcc/989_nestfield_run.c (#44/#55). For outer{a:u8, p:inner}
// the natural offset of p is 1, but a pre-fix slot-padded layout put it at 8, so
// construction (write) and field-access (read) disagreed and o.p.x / o.p.y read
// wrong. cstage build+run was T1; the original cat-A invariant (cs==ww exit)
// now rides the stronger T2 .s byte-id (test-lang-byteid).
//
// nested3's z proves post-composite accumulation stays natural (z follows the
// 1-byte-padded inner, not the 8-byte-padded one). flat_ctl is the no-sub-8-field
// control where natural and slot-padded layouts coincide.
package nestfield_test;
type inr = struct { x: u8, y: u8 };
type ot2 = struct { a: u8, p: inr };
type ot3 = struct { a: u8, p: inr, z: i64 };
type flt = struct { a: u8, b: i64 };
@test fn nested2() void = {
let o: ot2 = ot2 { a = 5, p = inr { x = 6, y = 7 } };
assert(o.a: int == 5);
assert(o.p.x: int == 6);
assert(o.p.y: int == 7);
};
@test fn nested3() void = {
let o: ot3 = ot3 { a = 1, p = inr { x = 2, y = 3 }, z = 0x44444444i64 };
assert(o.a: int == 1);
assert(o.p.x: int == 2);
assert(o.p.y: int == 3);
assert(o.z == 0x44444444i64);
};
@test fn flat_ctl() void = {
let o: flt = flt { a = 9, b = 0x33333333i64 };
assert(o.a: int == 9);
assert(o.b == 0x33333333i64);
};