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

35 lines
1.3 KiB
Plaintext

// structlit_arrfield_test — struct array-field init + read (global let/def and
// local lit). Migrated from test/wcc/949_structlit_arrfield_run.c (#249). BUG B:
// reading a [4]u8 field of a module-global struct SEGFAULTed on wwstage; BUG A:
// a local struct-lit array field fell to the scalar tail and dropped every
// element but the first. Fix = cg_structlit_fill array arm + def_isstructdef
// LOAD widening (ADDQ $field_off). cstage build+run was T1; cs==ww .s byte-id
// rides T2 (test-lang-byteid). The def row has a [3]u8 pad ahead of encmap, so
// the read exercises a non-zero field offset (the base64 std_encoding shape).
package structlit_arrfield_test;
type e1 = struct { encmap: [4]u8 };
let GE: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] };
type e2 = struct { pad: [3]u8, encmap: [4]u8 };
def GD: e2 = e2 { pad = [9u8, 9u8, 9u8], encmap = [65u8, 66u8, 67u8, 68u8] };
@test fn global_let_read() void = {
assert(GE.encmap[0]: i32 == 65);
};
@test fn global_def_read_off() void = {
assert(GD.encmap[2]: i32 == 67);
};
@test fn local_lit_read0() void = {
let g: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] };
assert(g.encmap[0]: i32 == 65);
};
@test fn local_lit_read3() void = {
let g: e1 = e1 { encmap = [65u8, 66u8, 67u8, 68u8] };
assert(g.encmap[3]: i32 == 68);
};