// match_nonident_idx_test — match on an N_INDEX scrutinee whose base is a // non-ident (struct-field slice, chained-dot slice, 56B-slot regex-inst union), // plus ident/ident-base controls. Pins arm-order independence and the stamped- // carrier resolve at any base depth. Migrated from // test/wcc/928_match_nonident_idx_run.c (value rows; C driver asserted cs==ww .s). package match_nonident_idx_test; type va = void; type vb = bool; type vc = size; type tu = (va | vb | vc); type holder = struct { xs: []tu, n: size }; type inner = struct { xs: []tu, k: size }; type outer = struct { in_: inner, n: size }; type big = struct { a: i64, b: i64, c: i64, d: i64, e: i64, f: i64 }; type ilit = struct { r: i64 }; type imatch = void; type inst = (big | ilit | imatch); type re = struct { insts: []inst, n: i64 }; @test fn field_slice_idx() void = { let sl: []tu = [(true: vb), ((7: size): vc)]; let h: holder; h.xs = sl; h.n = 2; match (h.xs[0]) { case let b: vb => { assert(b: bool); }; case => { assert(false); }; }; match (h.xs[1]) { case let s: vc => { assert((s: size) == 7); }; case => { assert(false); }; }; match (h.xs[0]) { case va => { assert(false); }; case let b: vb => { assert(b: bool); }; case vc => { assert(false); }; }; }; @test fn regex_inst_56b() void = { let sl: []inst; let l: ilit = ilit { r = 65 }; let v: inst = l; append(sl, v); let m: inst = void: imatch; append(sl, m); let r: re; r.insts = sl; r.n = 2; match (r.insts[0]) { case let x: ilit => { assert(x.r == 65); }; case => { assert(false); }; }; match (r.insts[1]) { case imatch => { }; case => { assert(false); }; }; match (r.insts[0]) { case big => { assert(false); }; case let x: ilit => { assert(x.r == 65); }; case imatch => { assert(false); }; }; }; @test fn dot_depth_idx() void = { let sl: []tu = [(true: vb), ((9: size): vc)]; let o: outer; o.in_.xs = sl; o.in_.k = 1; o.n = 2; match (o.in_.xs[0]) { case let b: vb => { assert(b: bool); }; case => { assert(false); }; }; match (o.in_.xs[1]) { case va => { assert(false); }; case let s: vc => { assert((s: size) == 9); }; case vb => { assert(false); }; }; }; @test fn ident_and_identbase_controls() void = { let v: tu = (true: vb); match (v) { case let b: vb => { assert(b: bool); }; case => { assert(false); }; }; let arr: [2]tu = [(true: vb), ((7: size): vc)]; match (arr[1]) { case let s: vc => { assert((s: size) == 7); }; case => { assert(false); }; }; let sl: []tu = [(true: vb), ((7: size): vc)]; match (sl[0]) { case let b: vb => { assert(b: bool); }; case => { assert(false); }; }; };