Files
ww/test/lang/valstruct_subsize_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

71 lines
1.8 KiB
Plaintext

// valstruct_subsize_test — sub-8 nested value-struct zero-init extent, local +
// global, distinct byte asserts. Migrated from
// test/wcc/949_valstruct_subsize_run.c. A nested {[N]u8} value-struct of ABI
// size 1/2/4 once emitted a stray MOVQ $0 (local) / 8 zero DATA bytes (global)
// on wwstage that cstage didn't. cstage build+run was T1; cs==ww .s byte-id
// rides T2 (test-lang-byteid).
//
// The D1/D2 rows WRITE then READ a byte so the value is deterministic (the
// robust falsifiable dimension). The ctl_*_16 rows are the negative control: a
// >8 multi-word value-struct still zero-inits — a wrongly-suppressed >8 zero arm
// would read stack garbage (and diverge from the still-zeroing cstage on the T2
// byte-id, which is the real guarantee for the unwritten read).
package valstruct_subsize_test;
type in4 = struct { m: [4]u8 };
type ov4 = struct { i: in4 };
type in2 = struct { m: [2]u8 };
type ov2 = struct { i: in2 };
type in1 = struct { m: [1]u8 };
type ov1 = struct { i: in1 };
type in16 = struct { m: [16]u8 };
type ov16 = struct { i: in16 };
let G4: ov4;
let G2: ov2;
let G1: ov1;
let G16: ov16;
@test fn d1_local_4() void = {
let o: ov4;
o.i.m[0] = 66u8;
assert(o.i.m[0]: i32 == 66);
};
@test fn d1_local_2() void = {
let o: ov2;
o.i.m[1] = 55u8;
assert(o.i.m[1]: i32 == 55);
};
@test fn d1_local_1() void = {
let o: ov1;
o.i.m[0] = 44u8;
assert(o.i.m[0]: i32 == 44);
};
@test fn d2_global_4() void = {
G4.i.m[0] = 66u8;
assert(G4.i.m[0]: i32 == 66);
};
@test fn d2_global_2() void = {
G2.i.m[1] = 55u8;
assert(G2.i.m[1]: i32 == 55);
};
@test fn d2_global_1() void = {
G1.i.m[0] = 44u8;
assert(G1.i.m[0]: i32 == 44);
};
@test fn ctl_local_16() void = {
let o: ov16;
assert(o.i.m[7]: i32 == 0);
};
@test fn ctl_global_16() void = {
assert(G16.i.m[7]: i32 == 0);
};