Files
ww/test/lang/tuple_index_read_test.ww
Hojun-Cho 07b3c74ab0 test: migrate Fam8 tuple value tests to @test + reject carriers (#5-C2)
fold-2 chunk C2 (drew's Fam8-13 plan): 14 tuple value-row C drivers migrate to
15 test/lang/*_test.ww @test row-tables (the +1 is 954_tuprecv, slimmed not
deleted -- its value rows split out while the asserttyped-stamp dimension stays
as a carrier-split C pin, mutation-proven non-vacuous). Reject rows move to 32
test/wcc/data/*/case.ww //ww:error carriers (runww asserts the substring in
BOTH stages). The test-lang byte-id (LANGBYTEID) gate gives cs==ww automatically
and is strictly more sensitive than re-running the wwstage leg; floor 59->74.
Tuple surfaced zero cs!=ww as the plan predicted -- no value-only carve. The 945
trio folds in here; 940_global_sret / 940_str_forrange / 926_tagscr untouched
(routed to drew per-file). Test count 402->388 = the 14 retired drivers.
2026-06-24 01:44:13 +09:00

62 lines
1.8 KiB
Plaintext

// tuple_index_read_test — #121: const-slice tuple-element READ. Migrated from
// test/wcc/947_tuple_index_read_run.c.
//
// Three legs of indexed-tuple read off a `const [](str,*fn)` (fold-6's
// charclass_map shape), all sharing the &tbl[i] place-spine (#116):
//
// field_read — direct `tbl[i].N` field read, was LOUD both stages.
// whole_element — `let e = tbl[i]` then read e.N, was SILENT both-wrong-
// IDENTICAL (#263, word0-only truncation). The runtime read-
// back with DISTINCT-per-row values is the net: a wrong word
// is CAUGHT, not masked.
// store_roundtrip — write-face: a tuple-LITERAL store `a[i] = (3,4)`, read
// back whole; DISTINCT words per row catch the word0-only
// store.
//
// The for-range-over-module-global LOUD-STOP reject row migrated to
// test/wcc/data/tupidx_forrange_global_loud/case.ww (K_BUILDERR). Every value
// row's cs==ww .s byte-id rides T2 (test-lang-byteid).
package tuple_index_read_test;
fn fa(c: rune) bool = { return c == 'a'; };
fn fz(c: rune) bool = { return c == 'z'; };
const tbl: [](str, *fn(c: rune) bool) = [("ab", &fa), ("cdef", &fz)];
@test fn field_read() void = {
let s1 = tbl[1].0;
let s0 = tbl[0].0;
assert(len(s1) == 4);
assert(len(s0) == 2);
let f1 = tbl[1].1;
assert((*f1)('z'));
assert(!((*f1)('a')));
let f0 = tbl[0].1;
assert((*f0)('a'));
assert(!((*f0)('z')));
};
@test fn whole_element() void = {
let e = tbl[1];
assert(len(e.0) == 4);
assert((*e.1)('z'));
assert(!((*e.1)('a')));
let e0 = tbl[0];
assert(len(e0.0) == 2);
assert((*e0.1)('a'));
assert(!((*e0.1)('z')));
};
@test fn store_roundtrip() void = {
let a: [2](u64, u64);
a[1] = (3u64, 4u64);
a[0] = (7u64, 9u64);
let t = a[1];
assert(t.0 == 3);
assert(t.1 == 4);
let s = a[0];
assert(s.0 == 7);
assert(s.1 == 9);
};