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

85 lines
2.3 KiB
Plaintext

// tuple_in_union_test — project #242: a mixed-scalar tuple wrapped in a tagged
// union must construct, match-bind, and destructure identically in both stages
// and round-trip every element. Migrated from test/wcc/940_tuple_in_union_run.c
// (K_RUN value rows). Three silent gate-blind cs!=ww divergences were met:
// cstage construction zeroed the whole value instead of packing the tuple
// variant; wwstage's checker left un-annotated destructure binders untyped for
// a non-call rhs; both stages destructured a tuple ident off a stale register
// cursor. The @test fns pin the runtime element values at variant 0 and at a
// non-zero variant index; T2 byte-id keeps cs==ww (rule 10). The K_BUILDERR
// bare-literal-element loud-stop row lives at test/wcc/data/tupunion_bool_literal/.
package tuple_in_union_test;
fn mku_bool_u64(x: u64, s: bool) ((bool, u64) | void) = { return (s, x); };
fn mku_void_arm(ok: bool, x: u64, s: bool) ((bool, u64) | void) = {
if (ok) { return (s, x); };
return;
};
fn mku_tuple_tag1(x: u64, s: bool) (void | (bool, u64)) = { return (s, x); };
fn mk_tuple_after_int(which: bool) (int | (bool, u64)) = {
let s: bool = true;
let v: u64 = 88u64;
if (which) { return (s, v); };
return 5;
};
fn f_eightbyte_share(a: i32, b: i32, c: u64) ((i32, i32, u64) | void) = {
return (a, b, c);
};
@test fn bool_u64() void = {
match (mku_bool_u64(7u64, true)) {
case let t: (bool, u64) => {
let (sg, u) = t;
assert(!(u != 7u64));
assert(!(!sg));
};
case void => { assert(false); };
};
};
@test fn void_arm() void = {
match (mku_void_arm(false, 1u64, true)) {
case let t: (bool, u64) => { assert(false); };
case void => { };
};
};
@test fn tuple_tag1() void = {
match (mku_tuple_tag1(9u64, true)) {
case void => { assert(false); };
case let t: (bool, u64) => {
let (sg, u) = t;
assert(!(u != 9u64));
assert(!(!sg));
};
};
};
@test fn tuple_after_int() void = {
match (mk_tuple_after_int(true)) {
case let n: int => { assert(false); };
case let t: (bool, u64) => {
let (sg, u) = t;
assert(!(u != 88u64));
assert(!(!sg));
};
};
};
@test fn eightbyte_share() void = {
match (f_eightbyte_share(-3, 4, 9u64)) {
case let t: (i32, i32, u64) => {
let (x, y, z) = t;
assert(!(x != -3));
assert(!(y != 4));
assert(!(z != 9u64));
};
case void => { assert(false); };
};
};