test: port 787/929 cross-module match carriers to corpus fixtures
787_xmod_variant_match.c -> r787_xmod_variant_no_default (run-exit 21), r787_xmod_variant_bind_default (42), r787_xmod_variant_shape_a (12) (pkg/errs module dirs), r787_xmod_variant_foreign_qualifier (staged error: w6c 'is not a variant of', w6c_ww rejects via the #95 ambiguity guard — the carrier asserted reject polarity only) 929_match_4arm_cross_module_run.c -> r929_match_{4arm_shadowed_ canonical,3arm_shadowed,5arm_shadowed,6arm_shadowed,4arm_mixed_kinds, 4arm_shadowed_reverse} (run; single-file a+b packages, dropping the carrier's accidental doubled 'package b;' line) 929's byte-id upgrades from 994-delegated to per-fixture via test-data-byteid; the asm-level distinct-CMPQ sentinel remains 728's separate concern. All rows probed green on both stages.
This commit is contained in:
17
test/wcc/data/r787_xmod_variant_bind_default/case.ww
Normal file
17
test/wcc/data/r787_xmod_variant_bind_default/case.ww
Normal file
@@ -0,0 +1,17 @@
|
||||
//ww:run-exit 42
|
||||
// migrated from test/wcc/787_xmod_variant_match.c: bare arm + bound `case let o: pkg.b` + default over an imported 3-variant union.
|
||||
package main;
|
||||
import pkg;
|
||||
fn classify(e: pkg.u2) i32 = {
|
||||
match (e) {
|
||||
case pkg.a => return 1;
|
||||
case let o: pkg.b => return 2;
|
||||
case => return 9;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
if (classify(pkg.mka()) != 1) { return 11; };
|
||||
if (classify(pkg.mkb()) != 2) { return 12; };
|
||||
if (classify(pkg.mkc()) != 9) { return 13; };
|
||||
return 42;
|
||||
};
|
||||
9
test/wcc/data/r787_xmod_variant_bind_default/pkg/pkg.ww
Normal file
9
test/wcc/data/r787_xmod_variant_bind_default/pkg/pkg.ww
Normal file
@@ -0,0 +1,9 @@
|
||||
// exports the 3-variant union for the r787 bind_and_default scenario.
|
||||
package pkg;
|
||||
export type a = !void;
|
||||
export type b = !void;
|
||||
export type c = !void;
|
||||
export type u2 = !(a | b | c);
|
||||
export fn mka() u2 = { let x: a; return x; };
|
||||
export fn mkb() u2 = { let y: b; return y; };
|
||||
export fn mkc() u2 = { let z: c; return z; };
|
||||
19
test/wcc/data/r787_xmod_variant_foreign_qualifier/case.ww
Normal file
19
test/wcc/data/r787_xmod_variant_foreign_qualifier/case.ww
Normal file
@@ -0,0 +1,19 @@
|
||||
//ww:error c "is not a variant of" ww "ambiguous without nominal layout"
|
||||
// migrated from test/wcc/787_xmod_variant_match.c: a same-leaf variant from a DIFFERENT module is NOT a variant of the scrutinee — guards #13 against bare leaf-strip false-accept.
|
||||
package pkg;
|
||||
export type a = !void;
|
||||
export type b = !void;
|
||||
export type u = !(a | b);
|
||||
export fn mka() u = { let x: a; return x; };
|
||||
package o;
|
||||
export type a = !void;
|
||||
package main;
|
||||
import pkg;
|
||||
import o;
|
||||
fn classify(e: pkg.u) i32 = {
|
||||
match (e) {
|
||||
case o.a => return 1;
|
||||
case => return 0;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = { return classify(pkg.mka()); };
|
||||
13
test/wcc/data/r787_xmod_variant_no_default/case.ww
Normal file
13
test/wcc/data/r787_xmod_variant_no_default/case.ww
Normal file
@@ -0,0 +1,13 @@
|
||||
//ww:run-exit 21
|
||||
// migrated from test/wcc/787_xmod_variant_match.c: cross-module bare-variant arms with NO default — casecovers exhaustiveness across modules (#13).
|
||||
package main;
|
||||
import pkg;
|
||||
fn classify(e: pkg.u) i32 = {
|
||||
match (e) {
|
||||
case pkg.a => return 1;
|
||||
case pkg.b => return 2;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
return classify(pkg.mkb()) * 10 + classify(pkg.mka());
|
||||
};
|
||||
7
test/wcc/data/r787_xmod_variant_no_default/pkg/pkg.ww
Normal file
7
test/wcc/data/r787_xmod_variant_no_default/pkg/pkg.ww
Normal file
@@ -0,0 +1,7 @@
|
||||
// exports !void variants + union for the r787 no-default scenario.
|
||||
package pkg;
|
||||
export type a = !void;
|
||||
export type b = !void;
|
||||
export type u = !(a | b);
|
||||
export fn mka() u = { let x: a; return x; };
|
||||
export fn mkb() u = { let y: b; return y; };
|
||||
14
test/wcc/data/r787_xmod_variant_shape_a/case.ww
Normal file
14
test/wcc/data/r787_xmod_variant_shape_a/case.ww
Normal file
@@ -0,0 +1,14 @@
|
||||
//ww:run-exit 12
|
||||
// migrated from test/wcc/787_xmod_variant_match.c: Shape A — a dotted body variant (errs.bad) keeps ITS OWN qualifier in case matching.
|
||||
package main;
|
||||
import pkg;
|
||||
import errs;
|
||||
fn classify(x: pkg.e) i32 = {
|
||||
match (x) {
|
||||
case errs.bad => return 1;
|
||||
case pkg.local => return 2;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
return classify(pkg.mkbad()) * 10 + classify(pkg.mklocal());
|
||||
};
|
||||
3
test/wcc/data/r787_xmod_variant_shape_a/errs/errs.ww
Normal file
3
test/wcc/data/r787_xmod_variant_shape_a/errs/errs.ww
Normal file
@@ -0,0 +1,3 @@
|
||||
// the foreign variant module for the r787 Shape A scenario.
|
||||
package errs;
|
||||
export type bad = !void;
|
||||
7
test/wcc/data/r787_xmod_variant_shape_a/pkg/pkg.ww
Normal file
7
test/wcc/data/r787_xmod_variant_shape_a/pkg/pkg.ww
Normal file
@@ -0,0 +1,7 @@
|
||||
// union whose BODY holds a dotted cross-module variant (errs.bad | local).
|
||||
package pkg;
|
||||
import errs;
|
||||
export type local = !void;
|
||||
export type e = !(errs.bad | local);
|
||||
export fn mkbad() e = { let x: errs.bad; return x; };
|
||||
export fn mklocal() e = { let y: local; return y; };
|
||||
26
test/wcc/data/r929_match_3arm_shadowed/case.ww
Normal file
26
test/wcc/data/r929_match_3arm_shadowed/case.ww
Normal file
@@ -0,0 +1,26 @@
|
||||
//ww:run
|
||||
// migrated from test/wcc/929_match_4arm_cross_module_run.c: 3-arm boundary — arm 2 must reach its body under the shadowed callee.
|
||||
package a;
|
||||
export type more = void;
|
||||
export type done = void;
|
||||
export fn next(k: i32) (rune | done | more) = {
|
||||
if (k == 0) { return 0x42u32: rune; };
|
||||
if (k == 1) { let v: done; return v; };
|
||||
let v: more; return v;
|
||||
};
|
||||
package b;
|
||||
import a;
|
||||
type done = void;
|
||||
fn next(k: i32) i32 = {
|
||||
match (a.next(k)) {
|
||||
case let r: rune => return 1i32 + (r: i32);
|
||||
case let dn: a.done => return 2;
|
||||
case let m: a.more => return 3;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
if (next(0) != 67) { return 11; };
|
||||
if (next(1) != 2) { return 12; };
|
||||
if (next(2) != 3) { return 13; };
|
||||
return 0;
|
||||
};
|
||||
26
test/wcc/data/r929_match_4arm_mixed_kinds/case.ww
Normal file
26
test/wcc/data/r929_match_4arm_mixed_kinds/case.ww
Normal file
@@ -0,0 +1,26 @@
|
||||
//ww:run
|
||||
// migrated from test/wcc/929_match_4arm_cross_module_run.c: mixed variant kinds (i32|str|rune|u8) — the shadowed-resolution fix is not shape-specific.
|
||||
package a;
|
||||
export fn next(k: i32) (i32 | str | rune | u8) = {
|
||||
if (k == 0) { return 7; };
|
||||
if (k == 1) { return "hi"; };
|
||||
if (k == 2) { return 0x45u32: rune; };
|
||||
return 9u8;
|
||||
};
|
||||
package b;
|
||||
import a;
|
||||
fn next(k: i32) i32 = {
|
||||
match (a.next(k)) {
|
||||
case let n: i32 => return 100 + n;
|
||||
case let s: str => return 200i32 + (s.len: i32);
|
||||
case let r: rune => return 300i32 + (r: i32);
|
||||
case let c: u8 => return 400i32 + (c: i32);
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
if (next(0) != 107) { return 11; };
|
||||
if (next(1) != 202) { return 12; };
|
||||
if (next(2) != 369) { return 13; };
|
||||
if (next(3) != 409) { return 14; };
|
||||
return 0;
|
||||
};
|
||||
30
test/wcc/data/r929_match_4arm_shadowed_canonical/case.ww
Normal file
30
test/wcc/data/r929_match_4arm_shadowed_canonical/case.ww
Normal file
@@ -0,0 +1,30 @@
|
||||
//ww:run
|
||||
// migrated from test/wcc/929_match_4arm_cross_module_run.c: canonical 4-arm — caller fn `next` shadows callee a.next; every arm body must fire (#31 fnretlookupmod).
|
||||
package a;
|
||||
export type more = void;
|
||||
export type invalid = !void;
|
||||
export type done = void;
|
||||
export fn next(k: i32) (rune | done | more | invalid) = {
|
||||
if (k == 0) { return 0x41u32: rune; };
|
||||
if (k == 1) { let v: done; return v; };
|
||||
if (k == 2) { let v: more; return v; };
|
||||
let v: invalid; return v;
|
||||
};
|
||||
package b;
|
||||
import a;
|
||||
type done = void;
|
||||
fn next(k: i32) i32 = {
|
||||
match (a.next(k)) {
|
||||
case let r: rune => return 100i32 + (r: i32);
|
||||
case let dn: a.done => return 200;
|
||||
case let m: a.more => return 300;
|
||||
case let e: a.invalid => return 400;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
if (next(0) != 165) { return 11; };
|
||||
if (next(1) != 200) { return 12; };
|
||||
if (next(2) != 300) { return 13; };
|
||||
if (next(3) != 400) { return 14; };
|
||||
return 0;
|
||||
};
|
||||
30
test/wcc/data/r929_match_4arm_shadowed_reverse/case.ww
Normal file
30
test/wcc/data/r929_match_4arm_shadowed_reverse/case.ww
Normal file
@@ -0,0 +1,30 @@
|
||||
//ww:run
|
||||
// migrated from test/wcc/929_match_4arm_cross_module_run.c: reverse arm order — dispatch follows the callee's variant indices, not source order.
|
||||
package a;
|
||||
export type more = void;
|
||||
export type invalid = !void;
|
||||
export type done = void;
|
||||
export fn next(k: i32) (rune | done | more | invalid) = {
|
||||
if (k == 0) { return 0x46u32: rune; };
|
||||
if (k == 1) { let v: done; return v; };
|
||||
if (k == 2) { let v: more; return v; };
|
||||
let v: invalid; return v;
|
||||
};
|
||||
package b;
|
||||
import a;
|
||||
type done = void;
|
||||
fn next(k: i32) i32 = {
|
||||
match (a.next(k)) {
|
||||
case let e: a.invalid => return 4;
|
||||
case let m: a.more => return 3;
|
||||
case let dn: a.done => return 2;
|
||||
case let r: rune => return 100i32 + (r: i32);
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
if (next(0) != 170) { return 11; };
|
||||
if (next(1) != 2) { return 12; };
|
||||
if (next(2) != 3) { return 13; };
|
||||
if (next(3) != 4) { return 14; };
|
||||
return 0;
|
||||
};
|
||||
34
test/wcc/data/r929_match_5arm_shadowed/case.ww
Normal file
34
test/wcc/data/r929_match_5arm_shadowed/case.ww
Normal file
@@ -0,0 +1,34 @@
|
||||
//ww:run
|
||||
// migrated from test/wcc/929_match_4arm_cross_module_run.c: 5-arm scaling — arms 3 and 4 must each reach their body.
|
||||
package a;
|
||||
export type more = void;
|
||||
export type invalid = !void;
|
||||
export type done = void;
|
||||
export type stop = void;
|
||||
export fn next(k: i32) (rune | done | more | invalid | stop) = {
|
||||
if (k == 0) { return 0x43u32: rune; };
|
||||
if (k == 1) { let v: done; return v; };
|
||||
if (k == 2) { let v: more; return v; };
|
||||
if (k == 3) { let v: invalid; return v; };
|
||||
let v: stop; return v;
|
||||
};
|
||||
package b;
|
||||
import a;
|
||||
type done = void;
|
||||
fn next(k: i32) i32 = {
|
||||
match (a.next(k)) {
|
||||
case let r: rune => return 100i32 + (r: i32);
|
||||
case let dn: a.done => return 2;
|
||||
case let m: a.more => return 3;
|
||||
case let e: a.invalid => return 4;
|
||||
case let s: a.stop => return 5;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
if (next(0) != 167) { return 11; };
|
||||
if (next(1) != 2) { return 12; };
|
||||
if (next(2) != 3) { return 13; };
|
||||
if (next(3) != 4) { return 14; };
|
||||
if (next(4) != 5) { return 15; };
|
||||
return 0;
|
||||
};
|
||||
38
test/wcc/data/r929_match_6arm_shadowed/case.ww
Normal file
38
test/wcc/data/r929_match_6arm_shadowed/case.ww
Normal file
@@ -0,0 +1,38 @@
|
||||
//ww:run
|
||||
// migrated from test/wcc/929_match_4arm_cross_module_run.c: 6-arm — every arm beyond the caller's variant count was broken, not just arm 2/3.
|
||||
package a;
|
||||
export type more = void;
|
||||
export type invalid = !void;
|
||||
export type done = void;
|
||||
export type stop = void;
|
||||
export type eof = void;
|
||||
export fn next(k: i32) (rune | done | more | invalid | stop | eof) = {
|
||||
if (k == 0) { return 0x44u32: rune; };
|
||||
if (k == 1) { let v: done; return v; };
|
||||
if (k == 2) { let v: more; return v; };
|
||||
if (k == 3) { let v: invalid; return v; };
|
||||
if (k == 4) { let v: stop; return v; };
|
||||
let v: eof; return v;
|
||||
};
|
||||
package b;
|
||||
import a;
|
||||
type done = void;
|
||||
fn next(k: i32) i32 = {
|
||||
match (a.next(k)) {
|
||||
case let r: rune => return 100i32 + (r: i32);
|
||||
case let dn: a.done => return 2;
|
||||
case let m: a.more => return 3;
|
||||
case let e: a.invalid => return 4;
|
||||
case let s: a.stop => return 5;
|
||||
case let f: a.eof => return 6;
|
||||
};
|
||||
};
|
||||
export fn main() i32 = {
|
||||
if (next(0) != 168) { return 11; };
|
||||
if (next(1) != 2) { return 12; };
|
||||
if (next(2) != 3) { return 13; };
|
||||
if (next(3) != 4) { return 14; };
|
||||
if (next(4) != 5) { return 15; };
|
||||
if (next(5) != 6) { return 16; };
|
||||
return 0;
|
||||
};
|
||||
Reference in New Issue
Block a user