fold-2 chunk C5 (drew's Fam8-13 plan), the highest-risk chunk: 21 match/tagged value-row C drivers re-homed. 20 -> test/lang/*_test.ww @test row-tables + 12 runww //ww:error carriers (both stages reject). The global-tag cluster (globtag*/globstructwiden/taggedderefstore/...), which sits on the #15/#17 global-ptr fix, was empirically probed byte-id CLEAN -- the predicted hotspot surfaced ZERO fresh cs!=ww. Carves: variant_chain_b95 #81 -> _runonly (genuinely diverges at HEAD); callret_bound277 #277 -> slim C pin (cs-runs/ww-rejects), mutation-gated. 929_tagged_memarg kept whole (SSE-ABI asm conformance). 19 drivers deleted, 944_variant_chain slimmed to the #277 pin. The match-on-tagged-struct-field divergence (former #26) probed RESOLVED for all its cited shapes (938 voidstr_field/recursion_torture, tagnorm dedup_match all byte-id cs==ww + value-correct) -- closed no-reproducer-at-HEAD, attribution to #15/#17 INFERRED. Those rows migrate as normal byte-id @test and serve as the REGRESSION SENTINEL for the inferred close (a resurgence trips the gate). LANGBYTEID floor 93->113; test count 374->355 (19 deleted; 929 + 944_variant_chain kept). do-not-auto-batch (926_tagscr/940_global_sret/940_str_forrange) untouched.
117 lines
2.7 KiB
Plaintext
117 lines
2.7 KiB
Plaintext
// match_slice_variant_test — a `(scalar | []T)` match must select the right arm
|
|
// and preserve the slice payload (len + first byte) across u8/i8/i32/u64/rune,
|
|
// in both variant orders, and compose with a trailing str arm. Migrated from
|
|
// test/wcc/926_match_slice_variant_run.c (value rows, cs==ww byte-id).
|
|
|
|
package match_slice_variant_test;
|
|
|
|
fn pick_u8(n: (u8 | []u8)) i32 = {
|
|
match (n) {
|
|
case let c: u8 => return c: i32;
|
|
case let s: []u8 => return 100i32 + (s.len: i32) + (s[0]: i32);
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
fn pick_slice_first(n: ([]u8 | u8)) i32 = {
|
|
match (n) {
|
|
case let s: []u8 => return 100i32 + (s.len: i32) + (s[0]: i32);
|
|
case let c: u8 => return c: i32;
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
fn pick_i8(n: (i8 | []i8)) i32 = {
|
|
match (n) {
|
|
case let c: i8 => return c: i32;
|
|
case let s: []i8 => return 100i32 + (s.len: i32) + (s[0]: i32);
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
fn pick_i32(n: (i32 | []i32)) i32 = {
|
|
match (n) {
|
|
case let c: i32 => return c;
|
|
case let s: []i32 => return 1000i32 + (s.len: i32) + s[0];
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
fn pick_u64(n: (u64 | []u64)) i32 = {
|
|
match (n) {
|
|
case let c: u64 => return c: i32;
|
|
case let s: []u64 => return 1000i32 + (s.len: i32) + (s[0]: i32);
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
fn pick_rune(n: (rune | []rune)) i32 = {
|
|
match (n) {
|
|
case let r: rune => return r: i32;
|
|
case let s: []rune => return 1000i32 + (s.len: i32) + (s[0]: i32);
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
fn pick3(n: (u8 | []u8 | str)) i32 = {
|
|
match (n) {
|
|
case let c: u8 => return c: i32;
|
|
case let s: []u8 => return 200i32 + (s.len: i32) + (s[0]: i32);
|
|
case let t: str => return 300i32 + (t.len: i32);
|
|
};
|
|
return -1;
|
|
};
|
|
|
|
@test fn u8_slice_u8() void = {
|
|
let buf: [3]u8;
|
|
buf[0] = 7u8; buf[1] = 8u8; buf[2] = 9u8;
|
|
assert(pick_u8(42u8) == 42);
|
|
assert(pick_u8(buf[0:3]) == 110);
|
|
};
|
|
|
|
@test fn slice_u8_then_u8() void = {
|
|
let buf: [3]u8;
|
|
buf[0] = 7u8; buf[1] = 8u8; buf[2] = 9u8;
|
|
assert(pick_slice_first(buf[0:3]) == 110);
|
|
assert(pick_slice_first(42u8) == 42);
|
|
};
|
|
|
|
@test fn i8_slice_i8() void = {
|
|
let buf: [2]i8;
|
|
buf[0] = 5i8; buf[1] = 6i8;
|
|
assert(pick_i8(11i8) == 11);
|
|
assert(pick_i8(buf[0:2]) == 107);
|
|
};
|
|
|
|
@test fn i32_slice_i32() void = {
|
|
let buf: [2]i32;
|
|
buf[0] = 33i32; buf[1] = 44i32;
|
|
assert(pick_i32(77i32) == 77);
|
|
assert(pick_i32(buf[0:2]) == 1035);
|
|
};
|
|
|
|
@test fn u64_slice_u64() void = {
|
|
let buf: [2]u64;
|
|
buf[0] = 41u64; buf[1] = 42u64;
|
|
assert(pick_u64(99u64) == 99);
|
|
assert(pick_u64(buf[0:2]) == 1043);
|
|
};
|
|
|
|
@test fn rune_slice_rune() void = {
|
|
let buf: [2]rune;
|
|
buf[0] = 'a'; buf[1] = 'b';
|
|
assert(pick_rune('Z') == 90);
|
|
assert(pick_rune(buf[0:2]) == 1099);
|
|
};
|
|
|
|
@test fn u8_slice_u8_str() void = {
|
|
let buf: [3]u8;
|
|
buf[0] = 1u8; buf[1] = 2u8; buf[2] = 3u8;
|
|
let a: i32 = pick3(5u8);
|
|
let b: i32 = pick3(buf[0:3]);
|
|
let c: i32 = pick3("hi");
|
|
assert(a == 5);
|
|
assert(b == 204);
|
|
assert(c == 302);
|
|
};
|