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.
This commit is contained in:
2026-06-25 01:32:32 +09:00
parent 4cb697af87
commit 74cc35d488
28 changed files with 647 additions and 2790 deletions

View File

@@ -0,0 +1,99 @@
// array_static_init_test — module-level 1D/2D/3D array static-init, element
// read. Migrated from test/wcc/919_array_static_init_run.c (#129 Phase A.3,
// #156). emit_array_lit_bytes recurses on a TY_ARRAY element (esz=etype->size,
// rule 13); cgindex leaves the sub-array ADDRESS for an array element so the
// outer index dereferences the right cell (#135 sister). cstage build+run was
// T1; cs==ww .s byte-id rides T2 (test-lang-byteid). The nested-array `...`
// repeat reject is the runww carrier test/wcc/data/arr_nested_ellipsis_reject.
//
// Float-element rows assert bit-exact incl negative elements (drew: exercise the
// sign-XOR byte-loop per element). The struct-with-array-field rows read the
// array-field elements directly (D1.buf[k], D2.m[i][j]): the old #137/#150 cs≠ww
// global-struct-field-base bug is CLOSED at HEAD, so the read is now cs==ww IDENT
// — the original deferred this to byte-id only because the bug was then open.
package array_static_init_test;
let A_U8: [4]u8 = [1u8, 2u8, 3u8, 4u8];
let A_U32: [4]u32 = [1u32, 2u32, 3u32, 4u32];
let A_U64: [2]u64 = [1u64, 2u64];
let A_INEG: [4]i32 = [-1, -2, -3, -4];
let A_F64: [4]f64 = [1.5, -2.5, 3.5, -4.5];
let A_F32: [4]f32 = [1.5f32, -2.5f32, 3.5f32, -4.5f32];
def DA_U32: [4]u32 = [11u32, 22u32, 33u32, 44u32];
def DA_F64: [4]f64 = [1.5, 2.5, 3.5, 4.5];
let A_UZ: [4]u8 = [0u8, 0u8, 0u8, 0u8];
let A_U1: [1]u8 = [7u8];
let A2D: [3][2]u64 = [[1u64,2u64],[3u64,4u64],[5u64,6u64]];
def DA2D: [3][2]u64 = [[1u64,2u64],[3u64,4u64],[5u64,6u64]];
let A2V: [3][2]u64 = [[10u64,11u64],[20u64,21u64],[30u64,31u64]];
let A28: [2][1]u32 = [[7u32],[9u32]];
let A2W: [2][2]u64 = [[1u64,2u64],[3u64,4u64]];
let A3D: [2][2][2]u8 = [[[1u8,2u8],[3u8,4u8]],[[5u8,6u8],[7u8,8u8]]];
type dt1 = struct { tag: i32, buf: [4]u8 };
let D1: dt1 = dt1{tag=42, buf=[1u8, 2u8, 3u8, 4u8]};
type dt2 = struct { tag: i32, m: [2][2]u64 };
let D2: dt2 = dt2{tag=42, m=[[1u64,2u64],[3u64,4u64]]};
fn bits64(v: f64) u64 = {
let x: f64 = v;
let p: *u64 = (&x): *u64;
return *p;
};
fn bits32(v: f32) u32 = {
let x: f32 = v;
let p: *u32 = (&x): *u32;
return *p;
};
fn at(i: i32, j: i32) u64 = { return A2V[i][j]; };
@test fn let_u8_arr() void = { assert(A_U8[0]: i32 == 1); };
@test fn let_u32_arr() void = { assert(A_U32[0]: i32 == 1); };
@test fn let_u64_arr() void = { assert(A_U64[0]: i32 == 1); };
@test fn let_i32_neg_arr() void = { assert(A_INEG[0] == -1); };
@test fn let_f64_arr() void = {
assert(bits64(A_F64[0]) == 0x3FF8000000000000u64);
assert(bits64(A_F64[1]) == 0xC004000000000000u64);
assert(bits64(A_F64[3]) == 0xC012000000000000u64);
};
@test fn let_f32_arr() void = {
assert(bits32(A_F32[0]) == 0x3FC00000u32);
assert(bits32(A_F32[1]) == 0xC0200000u32);
assert(bits32(A_F32[3]) == 0xC0900000u32);
};
@test fn def_u32_arr() void = { assert(DA_U32[0]: i32 == 11); };
@test fn def_f64_arr() void = {
assert(bits64(DA_F64[0]) == 0x3FF8000000000000u64);
assert(bits64(DA_F64[3]) == 0x4012000000000000u64);
};
@test fn let_struct_with_arr_field() void = {
assert(D1.tag == 42);
assert(D1.buf[0]: i32 == 1);
assert(D1.buf[3]: i32 == 4);
};
@test fn let_u8_zero_arr() void = { assert(A_UZ[0]: i32 == 0); };
@test fn let_u8_single() void = { assert(A_U1[0]: i32 == 7); };
@test fn let_2d_u64() void = { assert(A2D[1][0]: i32 == 3); };
@test fn def_2d_u64() void = { assert(DA2D[2][1]: i32 == 6); };
@test fn let_2d_varidx() void = { assert((at(1, 1) + at(2, 0)): i32 == 51); };
@test fn let_2d_u32_8byte() void = { assert(A28[1][0]: i32 == 9); };
@test fn let_2d_write() void = {
A2W[1][0] = 99u64;
assert((A2W[0][0] + A2W[0][1] + A2W[1][0] + A2W[1][1]): i32 == 106);
};
@test fn let_struct_2d_field() void = {
assert(D2.tag == 42);
assert(D2.m[1][0]: i32 == 3);
assert(D2.m[1][1]: i32 == 4);
};
@test fn let_3d_u8() void = { assert(A3D[1][1][0]: i32 == 7); };