// is_nonident_test — `e is T` on non-ident scrutinees (indexed, dot-field, // call-result, slice-variant, nullable (*T|void) on dot-field and ident). Each // pins both polarities. Migrated from test/wcc/927_is_nonident_run.c (value // rows; the C driver already asserted cs==ww .s, so byte-id holds). package is_nonident_test; type p48 = struct { a: i64, b: i64, c: i64, d: i64, e: i64, f: i64 }; type small = (p48 | bool); type holder = struct { v: small, k: i64 }; type val = (i64 | bool); type valslice = (i64 | []u8); type t = struct { a: i64 }; type maybe = (*t | void); type nholder = struct { m: maybe, k: i64 }; fn mk(flag: bool) val = { if (flag) { let b: bool = true; return b; }; let n: i64 = 7; return n; }; @test fn indexed() void = { let xs: []small; let b: bool = true; let v: small = b; append(xs, v); assert(xs.len != 0 && xs[xs.len - 1] is bool); assert(!(xs[xs.len - 1] is p48)); assert(xs[0] is bool); }; @test fn dot_field() void = { let b: bool = true; let h: holder = holder { v = b, k = 5 }; assert(h.v is bool); assert(!(h.v is p48)); }; @test fn call_result() void = { assert(mk(true) is bool); assert(mk(false) is i64); assert(!(mk(true) is i64)); }; @test fn slice_variant_indexed() void = { let xs: []valslice; let buf: [2]u8 = [1u8, 2u8]; let s: []u8 = buf[0:2]; let v: valslice = s; append(xs, v); let n: i64 = 5; let w: valslice = n; append(xs, w); assert(xs[0] is []u8); assert(xs[1] is i64); assert(!(xs[0] is i64)); }; @test fn nullable_dot_field() void = { let v: t = t { a = 5 }; let h: nholder = nholder { m = &v, k = 1 }; assert(h.m is *t); assert(!(h.m is void)); let h2: nholder = nholder { m = void, k = 2 }; assert(!(h2.m is *t)); assert(h2.m is void); }; @test fn nullable_ident() void = { let v: t = t { a = 5 }; let m: maybe = &v; assert(m is *t); assert(!(m is void)); let m2: maybe = void; assert(!(m2 is *t)); assert(m2 is void); }; @test fn ident_control() void = { let b: bool = true; let v: val = b; assert(v is bool); assert(!(v is i64)); };