Files
ww/test/lang/tupfieldsize_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

66 lines
2.2 KiB
Plaintext

// tupfieldsize_test — F7-c4 (#43) + #40: a for-range destructure over an array
// of tuples must stride by the tuple's TRUE size, and a slice/str/nested-tuple
// FIELD carries its full 24B width, not the 8B scalar default; the destructure
// LOAD-into-binding must copy the full extent of a sz>8 aggregate binding (the
// recurring dropped word is the CAP). Migrated from test/wcc/989_tupfieldsize_run.c.
//
// THE BUG (cat-A silent miscompile, gate-blind): wwstage paramfieldsize
// (selfhost/cmd/wcc/cgenstmt.ww) had no N_TSLICE / N_TTUPLE arm, so a `[]T`
// tuple-field sized 8 instead of its 24B header; and the destructure copy
// landed only the PTR word, dropping .len/.cap. The fix adds the N_TSLICE arm
// (tyslicesize()=24, rule-13) + the N_TTUPLE arm, and copies the binding's full
// extent (cgen.c N_FORRANGE + cgenstmt.ww cgforrange twin), aligning wwstage UP.
//
// The cap row slices the bases so cap != len, teething the recurring dropped
// CAP word; a ptr+len-only set would pass green while cap stayed stale.
//
// The C driver ran each row on both stages + asserted cs==ww exit; here the
// cstage run is test-lang (T1) and the byte-id is test-lang-byteid (T2).
package tupfieldsize_test;
@test fn len_read() void = {
let b0: []u8 = ['a', 'b'];
let b1: []u8 = ['x', 'y', 'z'];
let xs: [2]([]u8, i64);
xs[0] = (b0, 10);
xs[1] = (b1, 30);
let sum: i64 = 0;
for (let (b, n) .. xs) {
sum = sum + len(b): i64 + n;
};
assert(sum: int == 45);
};
@test fn cap_read() void = {
let base0: []u8 = ['a', 'b', 'c', 'd'];
let base1: []u8 = ['p', 'q', 'r', 's', 't'];
let xs: [2]([]u8, i64);
xs[0] = (base0[0:2], 10);
xs[1] = (base1[0:3], 30);
let sum: i64 = 0;
for (let (b, n) .. xs) {
sum = sum + b.cap: i64 + n;
};
assert(sum: int == 49);
};
@test fn ptr_read() void = {
let b0: []u8 = ['a', 'b'];
let b1: []u8 = ['x', 'y', 'z'];
let xs: [2]([]u8, i64);
xs[0] = (b0, 10);
xs[1] = (b1, 30);
let sum: i64 = 0;
for (let (b, n) .. xs) { sum = sum + b[0]: i64; };
assert(sum: int == 217);
};
@test fn scalar_tuple_ctl() void = {
let xs: [2](i64, i64);
xs[0] = (3, 10); xs[1] = (5, 30);
let sum: i64 = 0;
for (let (a, b) .. xs) { sum = sum + a + b; };
assert(sum: int == 48);
};