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:
62
test/lang/const_slice_aggregate_test.ww
Normal file
62
test/lang/const_slice_aggregate_test.ww
Normal file
@@ -0,0 +1,62 @@
|
||||
// const_slice_aggregate_test — module-level const slice of (str,*fn) tuple rows
|
||||
// + scalar &fn globals, DATA emit with element relocations. Migrated from
|
||||
// test/wcc/946_const_slice_aggregate_run.c (#117/#119). cstage build+run was T1;
|
||||
// cs==ww .s byte-id rides T2 (test-lang-byteid). The loud non-tuple-aggregate
|
||||
// reject is the runww carrier test/wcc/data/slice_of_str_reject.
|
||||
//
|
||||
// drew: CALL THROUGH the *fn reloc — a scalar-only / len-only assert is
|
||||
// reloc-blind. Each row calls each distinct fn back so a wrong/swapped reloc is
|
||||
// caught; the str-element relocs + per-row backing stride ride the T2 byte-id.
|
||||
// Whole-element word0 is the only correctly-loaded backing word (#121 read
|
||||
// constraint), so the fn-first / scalar-first orderings put the read target at
|
||||
// word0.
|
||||
|
||||
package const_slice_aggregate_test;
|
||||
|
||||
fn fa(c: rune) bool = { return c == 'a'; };
|
||||
fn fz(c: rune) bool = { return c == 'z'; };
|
||||
|
||||
const TBL_FN: [](*fn(c: rune) bool, str) = [(&fa, "aa"), (&fz, "zzz")];
|
||||
const TBL_SF: [](str, *fn(c: rune) bool) = [("aa", &fa), ("zzz", &fz)];
|
||||
const TBL_3: [](str, *fn(c: rune) bool) =
|
||||
[("a", &fa), ("bb", &fa), ("ccc", &fa)];
|
||||
const TSCAL: [](i64, str) = [(10i64, "a"), (20i64, "bb")];
|
||||
let PF: *fn(c: rune) bool = &fa;
|
||||
let PG: *fn(c: rune) bool = &fz;
|
||||
|
||||
@test fn fnfirst_reloc() void = {
|
||||
let e0 = TBL_FN[0];
|
||||
let e1 = TBL_FN[1];
|
||||
let f0 = e0.0;
|
||||
let f1 = e1.0;
|
||||
assert((*f0)('a'));
|
||||
assert(!(*f0)('z'));
|
||||
assert((*f1)('z'));
|
||||
assert(!(*f1)('a'));
|
||||
assert(len(TBL_FN) == 2);
|
||||
};
|
||||
|
||||
@test fn consumer_str_fn() void = {
|
||||
assert(len(TBL_SF) == 2);
|
||||
};
|
||||
|
||||
@test fn consumer_3row() void = {
|
||||
assert(len(TBL_3) == 3);
|
||||
};
|
||||
|
||||
@test fn scalar_tuple_slice() void = {
|
||||
let e0 = TSCAL[0];
|
||||
let e1 = TSCAL[1];
|
||||
let v0 = e0.0;
|
||||
let v1 = e1.0;
|
||||
assert(v0 == 10);
|
||||
assert(v1 == 20);
|
||||
assert(len(TSCAL) == 2);
|
||||
};
|
||||
|
||||
@test fn scalar_fnptr() void = {
|
||||
assert((*PF)('a'));
|
||||
assert(!(*PF)('z'));
|
||||
assert((*PG)('z'));
|
||||
assert(!(*PG)('a'));
|
||||
};
|
||||
Reference in New Issue
Block a user