Every section banner dies (103 -> 0) across test/lang, the observer suites, the C carriers, and the five comment-heavy corpus fixtures; banner provenance (#N cites, carrier numbers, repair-cluster labels) folded into headers or adjacent WHY comments. Narration deleted; row provenance, ref cites, divergence pins, and layout contracts kept (fwd-ref decl-order guards and bootstrap-gate corpus rationale restored where the sweep over-cut). Comment-only proven: all 3742 wwbuild workdir .s byte-identical before/after; test-commit and test-byteid (161 lang + 1399 data, 0 pinned-divergent) green.
63 lines
1.9 KiB
Plaintext
63 lines
1.9 KiB
Plaintext
// 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'));
|
|
};
|