// #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); };