diff --git a/lib/crypto/sha256/sha256_test.ww b/lib/crypto/sha256/sha256_test.ww index 4e593ffc..e12336fd 100644 --- a/lib/crypto/sha256/sha256_test.ww +++ b/lib/crypto/sha256/sha256_test.ww @@ -4,9 +4,9 @@ // // The digest is the cgen-correctness oracle for u32 wrapping arithmetic // + the hash-vtable dispatch: any u32-overflow / rotate miscompile shows -// up as a byte mismatch. Same signalled-then-fail()-with-+10 pattern as -// the rest of the 9xx stdlib tests; the non-zero exit pinpoints the -// failing case. Expected digests come through the (separately tested) +// up as a byte mismatch. A failing row aborts via the assert/abort +// builtin (task #5 @test conversion). Expected digests come through the +// (separately tested) // hex.decodestr so the vectors stay readable. package sha256_test; @@ -16,10 +16,7 @@ import errors; import hash; import encoding.hex; import strings; -import os; -let signalled: i32 = 0; -fn fail() void = { os.exit(signalled + 10); }; // dohash — one-shot hash of `msg` into the caller's `out` (>= 32 bytes). // Mirrors the sum()-writes-into-a-buffer API (no array-by-value return). @@ -33,9 +30,9 @@ fn dohash(msg: []u8, out: []u8) void = { fn checkbytes(got: []u8, want: str) void = { match (hex.decodestr(want)) { case let w: []u8 => { - if (!bytes.equal(got, w)) { fail(); }; + assert(!(!bytes.equal(got, w))); }; - case let e: errors.invalid => fail(); + case let e: errors.invalid => abort(); }; }; @@ -105,7 +102,7 @@ fn check(msg: []u8, want: str) void = { let out2: [32]u8; hash.sum(h, out1[0:32]); hash.sum(h, out2[0:32]); - if (!bytes.equal(out1[0:32], out2[0:32])) { fail(); }; + assert(!(!bytes.equal(out1[0:32], out2[0:32]))); checkbytes(out1[0:32], "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"); @@ -116,23 +113,23 @@ fn check(msg: []u8, want: str) void = { hash.sum(h, out3[0:32]); let want: [32]u8; dohash(strings.toutf8("abcdef"), want[0:32]); - if (!bytes.equal(out3[0:32], want[0:32])) { fail(); }; + assert(!(!bytes.equal(out3[0:32], want[0:32]))); }; // sz()/bsz() report the SHA-256 constants regardless of state. @test fn sizes() void = { let st: sha256.state = sha256.sha256(); let h: *hash.hash = (&st): *hash.hash; - if (hash.sz(h) != 32: size) { fail(); }; - if (hash.bsz(h) != 64: size) { fail(); }; + assert(!(hash.sz(h) != 32: size)); + assert(!(hash.bsz(h) != 64: size)); }; export fn main() i32 = { - signalled = 1; empty(); - signalled = 2; abc(); - signalled = 3; twoblockpad(); - signalled = 4; millionas(); - signalled = 5; reentrant(); - signalled = 6; sizes(); + empty(); + abc(); + twoblockpad(); + millionas(); + reentrant(); + sizes(); return 0; }; diff --git a/lib/getopt/getopttest.ww b/lib/getopt/getopttest.ww index ed33058c..941e9096 100644 --- a/lib/getopt/getopttest.ww +++ b/lib/getopt/getopttest.ww @@ -26,19 +26,6 @@ import io; import memio; import strings; -// Direct exit(2) binding rather than `use os;` — os exports -// read/write/close, mirroring memio's reasoning (task #7). -@symbol("rt_syscall") fn syscall1ww(num: i64, a: i64) i64; -fn doexit(code: i32) void = { - syscall1ww(60i64, code: i64); -}; - -// signalled — bumped by main before each test so a failing exit code -// pinpoints the offending case. -let signalled: i32 = 0; - -fn fail() void = { doexit(signalled + 10); }; - fn streq(a: str, b: str) bool = { if (a.len != b.len) { return false; }; let i: i32 = 0; @@ -68,10 +55,10 @@ fn streq(a: str, b: str) bool = { let r: (void | getopt.error) = getopt.tryparse(&cmd, argv[0:3], helps[0:5]); match (r) { case void => {}; - case let e: getopt.error => fail(); + case let e: getopt.error => abort(); }; - if (cmd.optslen != 4) { fail(); }; + assert(!(cmd.optslen != 4)); // (wantflag, wantval) parallel arrays, indexed by option order. let wantf: [4]u8; @@ -84,13 +71,13 @@ fn streq(a: str, b: str) bool = { let i: i32 = 0; for (i < 4) { let p: *getopt.option = &cmd.optsptr[i]; - if ((p.flag: u8) != wantf[i]) { fail(); }; - if (!streq(p.value, wantv[i])) { fail(); }; + assert(!((p.flag: u8) != wantf[i])); + assert(!(!streq(p.value, wantv[i]))); i += 1; }; - if (cmd.argslen != 1) { fail(); }; - if (!streq(cmd.argsptr[0], "files.txt")) { fail(); }; + assert(!(cmd.argslen != 1)); + assert(!(!streq(cmd.argsptr[0], "files.txt"))); getopt.finish(&cmd); }; @@ -114,10 +101,10 @@ fn streq(a: str, b: str) bool = { let r: (void | getopt.error) = getopt.tryparse(&cmd, argv[0:5], helps[0:3]); match (r) { case void => {}; - case let e: getopt.error => fail(); + case let e: getopt.error => abort(); }; - if (cmd.optslen != 2) { fail(); }; + assert(!(cmd.optslen != 2)); let wantf: [2]u8; let wantv: [2]str; @@ -127,13 +114,13 @@ fn streq(a: str, b: str) bool = { let i: i32 = 0; for (i < 2) { let p: *getopt.option = &cmd.optsptr[i]; - if ((p.flag: u8) != wantf[i]) { fail(); }; - if (!streq(p.value, wantv[i])) { fail(); }; + assert(!((p.flag: u8) != wantf[i])); + assert(!(!streq(p.value, wantv[i]))); i += 1; }; - if (cmd.argslen != 1) { fail(); }; - if (!streq(cmd.argsptr[0], "-")) { fail(); }; + assert(!(cmd.argslen != 1)); + assert(!(!streq(cmd.argsptr[0], "-"))); getopt.finish(&cmd); }; @@ -177,12 +164,12 @@ fn streq(a: str, b: str) bool = { let r: (void | getopt.error) = getopt.tryparse(&cmd, argv, helps[0:2]); match (r) { case void => {}; - case let e: getopt.error => fail(); + case let e: getopt.error => abort(); }; - if (cmd.optslen != wantopts[i]) { fail(); }; - if (cmd.argslen != wantargs[i]) { fail(); }; + assert(!(cmd.optslen != wantopts[i])); + assert(!(cmd.argslen != wantargs[i])); if (cmd.argslen > 0) { - if (!streq(cmd.argsptr[0], wantarg0[i])) { fail(); }; + assert(!(!streq(cmd.argsptr[0], wantarg0[i]))); }; getopt.finish(&cmd); i += 1; @@ -204,18 +191,18 @@ fn streq(a: str, b: str) bool = { let r: (void | getopt.error) = getopt.tryparse(&cmd, argv[0:2], helps[0:2]); match (r) { case void => {}; - case let e: getopt.error => fail(); + case let e: getopt.error => abort(); }; - if (cmd.optslen != 3) { fail(); }; + assert(!(cmd.optslen != 3)); let i: i32 = 0; for (i < 3) { let p: *getopt.option = &cmd.optsptr[i]; - if ((p.flag: u8) != ('v': u8)) { fail(); }; - if (p.value.len != 0) { fail(); }; + assert(!((p.flag: u8) != ('v': u8))); + assert(!(p.value.len != 0)); i += 1; }; - if (cmd.argslen != 0) { fail(); }; + assert(!(cmd.argslen != 0)); getopt.finish(&cmd); }; @@ -257,13 +244,13 @@ fn streq(a: str, b: str) bool = { let r: (void | getopt.error) = getopt.tryparse(&cmd, argv, helps[0:2]); match (r) { case void => {}; - case let e: getopt.error => fail(); + case let e: getopt.error => abort(); }; - if (cmd.optslen != wantopts[i]) { fail(); }; - if (cmd.argslen != wantargs[i]) { fail(); }; + assert(!(cmd.optslen != wantopts[i])); + assert(!(cmd.argslen != wantargs[i])); // First positional is always the bare "-" in these rows. if (cmd.argslen > 0) { - if (!streq(cmd.argsptr[0], "-")) { fail(); }; + assert(!(!streq(cmd.argsptr[0], "-"))); }; getopt.finish(&cmd); i += 1; @@ -307,11 +294,11 @@ fn streq(a: str, b: str) bool = { let cmd: getopt.command; let r: (void | getopt.error) = getopt.tryparse(&cmd, argv, helps[0:3]); match (r) { - case void => fail(); + case void => abort(); case let e: getopt.error => { - if ((e.kind: i32) != wantk[i]) { fail(); }; - if ((e.flag: u8) != wantf[i]) { fail(); }; - if (!streq(e.name, "prog")) { fail(); }; + assert(!((e.kind: i32) != wantk[i])); + assert(!((e.flag: u8) != wantf[i])); + assert(!(!streq(e.name, "prog"))); }; }; getopt.finish(&cmd); @@ -340,7 +327,7 @@ fn streq(a: str, b: str) bool = { e.flag = flags[i]: rune; e.name = names[i]; let s: str = getopt.strerror(&e); - if (!streq(s, wants[i])) { fail(); }; + assert(!(!streq(s, wants[i]))); i += 1; }; }; @@ -381,12 +368,12 @@ fn streq(a: str, b: str) bool = { let r: (void | getopt.error) = getopt.tryparse(&cmd, argv, helps[0:2]); match (r) { case void => {}; - case let e: getopt.error => fail(); + case let e: getopt.error => abort(); }; - if (cmd.optslen != 0) { fail(); }; - if (cmd.argslen != wantargs[i]) { fail(); }; + assert(!(cmd.optslen != 0)); + assert(!(cmd.argslen != wantargs[i])); if (cmd.argslen > 0) { - if (!streq(cmd.argsptr[0], wantarg0[i])) { fail(); }; + assert(!(!streq(cmd.argsptr[0], wantarg0[i]))); }; getopt.finish(&cmd); i += 1; @@ -439,10 +426,10 @@ fn streq(a: str, b: str) bool = { hs.cap = hcnt[i]; match (getopt.printusage(h, names[i], hs)) { case void => {}; - case let e: io.error => fail(); + case let e: io.error => abort(); }; let got: str = memio.string(&ms); - if (!streq(got, wants[i])) { fail(); }; + assert(!(!streq(got, wants[i]))); i += 1; }; }; @@ -482,24 +469,24 @@ fn streq(a: str, b: str) bool = { let h: io.handle = s: io.handle; match (getopt.printhelp(h, names[i], helps[0:hcnt[i]])) { case void => {}; - case let e: io.error => fail(); + case let e: io.error => abort(); }; let got: str = memio.string(&ms); - if (!streq(got, wants[i])) { fail(); }; + assert(!(!streq(got, wants[i]))); i += 1; }; }; export fn main() i32 = { - signalled = 1; flagcluster(); - signalled = 2; paramflag(); - signalled = 3; separator(); - signalled = 4; repeatedflag(); - signalled = 5; baredash(); - signalled = 6; errortable(); - signalled = 7; strerrortext(); - signalled = 8; nooptionsbare(); - signalled = 9; printusage_cases(); - signalled = 10; printhelp_cases(); + flagcluster(); + paramflag(); + separator(); + repeatedflag(); + baredash(); + errortable(); + strerrortext(); + nooptionsbare(); + printusage_cases(); + printhelp_cases(); return 0; }; diff --git a/lib/path/pathtest.ww b/lib/path/pathtest.ww index 262f55d6..140e04fb 100644 --- a/lib/path/pathtest.ww +++ b/lib/path/pathtest.ww @@ -1,7 +1,6 @@ // pathtest — exercises lib/path (c2-stack subset). Run with -// `out/bin/ww run lib/path/pathtest.ww`. Same signalled-then-fail() -// -with-+10 pattern as bytes / getopt tests: a non-zero exit code -// pinpoints the failing scenario. +// `out/bin/ww run lib/path/pathtest.ww`. A failing row aborts via the +// assert/abort builtin (task #5 @test conversion). // // Vectors mirror Hare's @test fns in ref/hare/path/stack.ha:77-119 // and buffer.ha. The absolute rows (Hare's `local("/")`-seeded) DEFER @@ -16,10 +15,7 @@ package path_test; import path; -import os; -let signalled: i32 = 0; -fn fail() void = { os.exit(signalled + 10); }; // ---- push() + appendnorm normalization -------------------------------- // ref/hare/path/stack.ha:77-119 (relative rows only; absolute local() @@ -29,7 +25,7 @@ fn fail() void = { os.exit(signalled + 10); }; @test fn push_cases() void = { let buf = buffer { ... }; - if (string(&buf) != ".") { fail(); }; + assert(!(string(&buf) != ".")); // current-dir + parent-dir invariants (stack.ha:82-88). Single // segment per row → table-driven sequential apply. @@ -42,13 +38,13 @@ fn fail() void = { os.exit(signalled + 10); }; segs[4]="."; wants[4]=".."; let i: i32 = 0; for (i < 5) { - if (push(&buf, segs[i])! != wants[i]) { fail(); }; + assert(!(push(&buf, segs[i])! != wants[i])); i += 1; }; // set(&buf) resets to "." (stack.ha:91). set forwards an EMPTY // variadic into push (KEN-oracle flag 1: zero-arg gather+forward). - if (set(&buf)! != ".") { fail(); }; + assert(!(set(&buf)! != ".")); // regular path + parent (stack.ha:101-104, minus the local() row). let segs2: [3]str; @@ -58,25 +54,25 @@ fn fail() void = { os.exit(signalled + 10); }; segs2[2]=".."; wants2[2]="."; let k: i32 = 0; for (k < 3) { - if (push(&buf, segs2[k])! != wants2[k]) { fail(); }; + assert(!(push(&buf, segs2[k])! != wants2[k])); k += 1; }; // multi-segment (stack.ha:107-111). Variadic arity varies (1 or 2) // → inline. - if (push(&buf, "a", "b")! != "a/b") { fail(); }; - if (push(&buf, "..", "c")! != "a/c") { fail(); }; - if (push(&buf, "..")! != "a") { fail(); }; + assert(!(push(&buf, "a", "b")! != "a/b")); + assert(!(push(&buf, "..", "c")! != "a/c")); + assert(!(push(&buf, "..")! != "a")); // stack.ha:110; local()→literal, SEP='/' on Linux, proper local() rides c3 - if (push(&buf, "/d")! != "a/d") { fail(); }; - if (push(&buf, "..", "..")! != ".") { fail(); }; // stack.ha:111 + assert(!(push(&buf, "/d")! != "a/d")); + assert(!(push(&buf, "..", "..")! != ".")); // stack.ha:111 // leading-SEP segment into an EMPTY buffer exercises push's // `j==0 && buf.end==0` root-seed arm (stack.ha:18-20), unreached // by the relative rows above. Hare covers it via local("/")-seeded // rows that defer to c3; literal "/foo" stands in (SEP='/' on Linux). - if (set(&buf)! != ".") { fail(); }; - if (push(&buf, "/foo")! != "/foo") { fail(); }; + assert(!(set(&buf)! != ".")); + assert(!(push(&buf, "/foo")! != "/foo")); }; // ---- abs() ------------------------------------------------------------ @@ -95,18 +91,18 @@ fn fail() void = { os.exit(signalled + 10); }; for (i < 4) { let got: i32 = 0; if (abs(ins[i])) { got = 1; }; - if (got != want[i]) { fail(); }; + assert(!(got != want[i])); i += 1; }; // buffer-arm: &buf ptr-ident-widens into the union. let buf = buffer { ... }; - if (abs(&buf)) { fail(); }; // empty → false - if (push(&buf, "/foo")! != "/foo") { fail(); }; - if (!abs(&buf)) { fail(); }; // "/foo" → true + assert(!(abs(&buf))); // empty → false + assert(!(push(&buf, "/foo")! != "/foo")); + assert(!(!abs(&buf))); // "/foo" → true buf.end = 0; - if (push(&buf, "foo")! != "foo") { fail(); }; - if (abs(&buf)) { fail(); }; // "foo" → false + assert(!(push(&buf, "foo")! != "foo")); + assert(!(abs(&buf))); // "foo" → false }; // ---- isroot() --------------------------------------------------------- @@ -117,22 +113,22 @@ fn fail() void = { os.exit(signalled + 10); }; @test fn isroot_cases() void = { let buf = buffer { ... }; // empty buffer (end 0) - if (isroot(&buf)) { fail(); }; + assert(!(isroot(&buf))); // "/" — root. local() is c3, so seed the SEP byte directly. buf.buf[0] = SEP; buf.end = 1; - if (!isroot(&buf)) { fail(); }; - if (string(&buf) != "/") { fail(); }; + assert(!(!isroot(&buf))); + assert(!(string(&buf) != "/")); // "foo" — relative, not root. buf.end = 0; - if (push(&buf, "foo")! != "foo") { fail(); }; - if (isroot(&buf)) { fail(); }; + assert(!(push(&buf, "foo")! != "foo")); + assert(!(isroot(&buf))); // "/foo" — absolute but not root. buf.buf[0] = SEP; buf.end = 1; - if (push(&buf, "foo")! != "/foo") { fail(); }; - if (isroot(&buf)) { fail(); }; + assert(!(push(&buf, "foo")! != "/foo")); + assert(!(isroot(&buf))); // str-arm (buffer.ha:47): only the bare separator is root. let ins: [4]str; @@ -145,7 +141,7 @@ fn fail() void = { os.exit(signalled + 10); }; for (i < 4) { let got: i32 = 0; if (isroot(ins[i])) { got = 1; }; - if (got != want[i]) { fail(); }; + assert(!(got != want[i])); i += 1; }; }; @@ -156,9 +152,9 @@ fn fail() void = { os.exit(signalled + 10); }; @test fn string_cases() void = { let buf = buffer { ... }; - if (string(&buf) != ".") { fail(); }; - if (push(&buf, "foo")! != "foo") { fail(); }; - if (string(&buf) != "foo") { fail(); }; + assert(!(string(&buf) != ".")); + assert(!(push(&buf, "foo")! != "foo")); + assert(!(string(&buf) != "foo")); }; // ---- dirname() / basename() ------------------------------------------- @@ -188,8 +184,8 @@ fn fail() void = { os.exit(signalled + 10); }; inputs[9]="/home//dwc//test"; wantdir[9]="/home//dwc"; wantbase[9]="test"; let i: i32 = 0; for (i < 10) { - if (dirname(inputs[i]) != wantdir[i]) { fail(); }; - if (basename(inputs[i]) != wantbase[i]) { fail(); }; + assert(!(dirname(inputs[i]) != wantdir[i])); + assert(!(basename(inputs[i]) != wantbase[i])); i += 1; }; }; @@ -208,7 +204,7 @@ fn fail() void = { os.exit(signalled + 10); }; ins[3]=""; want[3]=""; let i: i32 = 0; for (i < 4) { - if (local(ins[i])! != want[i]) { fail(); }; + assert(!(local(ins[i])! != want[i])); i += 1; }; }; @@ -232,7 +228,7 @@ fn fail() void = { os.exit(signalled + 10); }; for (i < 5) { buf.end = 0; push(&buf, ins[i])!; - if (parent(&buf)! != want[i]) { fail(); }; + assert(!(parent(&buf)! != want[i])); i += 1; }; }; @@ -247,39 +243,39 @@ fn fail() void = { os.exit(signalled + 10); }; let buf = buffer { ... }; // empty - if (!(pop(&buf) is void)) { fail(); }; - if (string(&buf) != ".") { fail(); }; + assert(!(!(pop(&buf) is void))); + assert(!(string(&buf) != ".")); // root dir buf.end = 0; - if (push(&buf, "/")! != "/") { fail(); }; - if (!(pop(&buf) is void)) { fail(); }; - if (string(&buf) != "/") { fail(); }; + assert(!(push(&buf, "/")! != "/")); + assert(!(!(pop(&buf) is void))); + assert(!(string(&buf) != "/")); // relative file — peek is NON-mutating buf.end = 0; - if (push(&buf, "foo")! != "foo") { fail(); }; - if (peek(&buf) as str != "foo") { fail(); }; - if (string(&buf) != "foo") { fail(); }; - if (pop(&buf) as str != "foo") { fail(); }; - if (string(&buf) != ".") { fail(); }; + assert(!(push(&buf, "foo")! != "foo")); + assert(!(peek(&buf) as str != "foo")); + assert(!(string(&buf) != "foo")); + assert(!(pop(&buf) as str != "foo")); + assert(!(string(&buf) != ".")); // absolute file buf.end = 0; - if (push(&buf, "/foo")! != "/foo") { fail(); }; - if (peek(&buf) as str != "foo") { fail(); }; - if (pop(&buf) as str != "foo") { fail(); }; - if (string(&buf) != "/") { fail(); }; + assert(!(push(&buf, "/foo")! != "/foo")); + assert(!(peek(&buf) as str != "foo")); + assert(!(pop(&buf) as str != "foo")); + assert(!(string(&buf) != "/")); }; export fn main() i32 = { - signalled = 1; push_cases(); - signalled = 2; isroot_cases(); - signalled = 3; string_cases(); - signalled = 4; dirname_basename_cases(); - signalled = 5; abs_cases(); - signalled = 6; local_cases(); - signalled = 7; parent_cases(); - signalled = 8; popsplit_cases(); + push_cases(); + isroot_cases(); + string_cases(); + dirname_basename_cases(); + abs_cases(); + local_cases(); + parent_cases(); + popsplit_cases(); return 0; }; diff --git a/lib/regex/regex_test.ww b/lib/regex/regex_test.ww index 4b617c63..fd36a3de 100644 --- a/lib/regex/regex_test.ww +++ b/lib/regex/regex_test.ww @@ -19,9 +19,8 @@ // (including the nominally-distinct same-underlying // inst_split/inst_jump/inst_groupstart `size` aliases and the // inst_any/inst_skip/inst_groupend `void` aliases), payload extraction, -// the regex/capture struct shapes, and finish(). Same -// signalled-then-fail()-with-+10 pattern as the rest of the stdlib -// run-tests; the non-zero exit pinpoints the failing case. +// the regex/capture struct shapes, and finish(). A failing row aborts +// via the assert/abort builtin (task #5 @test conversion). // // Struct literals below name the type UNQUALIFIED (`inst_charset { … }`, // not `regex.inst_charset { … }`): the parser rejects a module-qualified @@ -32,25 +31,22 @@ package regex_test; import regex; import io; import memio; -import os; import strings; import types; -let signalled: i32 = 0; -fn fail() void = { os.exit(signalled + 10); }; // inst_lit / inst_match carry distinguishable payloads (rune / bool). @test fn lit_and_match() void = { let a: regex.inst = ('a': regex.inst_lit); match (a) { - case let l: regex.inst_lit => { if ((l: rune) != 'a') { fail(); }; }; - case => fail(); + case let l: regex.inst_lit => { assert(!((l: rune) != 'a')); }; + case => abort(); }; let m: regex.inst = (true: regex.inst_match); match (m) { - case let b: regex.inst_match => { if (!(b: bool)) { fail(); }; }; - case => fail(); + case let b: regex.inst_match => { assert(!(!(b: bool))); }; + case => abort(); }; }; @@ -60,24 +56,24 @@ fn fail() void = { os.exit(signalled + 10); }; @test fn size_aliases_distinct() void = { let sp: regex.inst = ((5: size): regex.inst_split); match (sp) { - case let s: regex.inst_split => { if ((s: size) != (5: size)) { fail(); }; }; - case let j: regex.inst_jump => fail(); - case let g: regex.inst_groupstart => fail(); - case => fail(); + case let s: regex.inst_split => { assert(!((s: size) != (5: size))); }; + case let j: regex.inst_jump => abort(); + case let g: regex.inst_groupstart => abort(); + case => abort(); }; let jp: regex.inst = ((9: size): regex.inst_jump); match (jp) { - case let j: regex.inst_jump => { if ((j: size) != (9: size)) { fail(); }; }; - case let s: regex.inst_split => fail(); - case => fail(); + case let j: regex.inst_jump => { assert(!((j: size) != (9: size))); }; + case let s: regex.inst_split => abort(); + case => abort(); }; let gs: regex.inst = ((2: size): regex.inst_groupstart); match (gs) { - case let g: regex.inst_groupstart => { if ((g: size) != (2: size)) { fail(); }; }; - case let s: regex.inst_split => fail(); - case => fail(); + case let g: regex.inst_groupstart => { assert(!((g: size) != (2: size))); }; + case let s: regex.inst_split => abort(); + case => abort(); }; }; @@ -87,26 +83,26 @@ fn fail() void = { os.exit(signalled + 10); }; let an: regex.inst = av; match (an) { case let a: regex.inst_any => void; - case let k: regex.inst_skip => fail(); - case let e: regex.inst_groupend => fail(); - case => fail(); + case let k: regex.inst_skip => abort(); + case let e: regex.inst_groupend => abort(); + case => abort(); }; let sv: regex.inst_skip; let sk: regex.inst = sv; match (sk) { case let k: regex.inst_skip => void; - case let a: regex.inst_any => fail(); - case => fail(); + case let a: regex.inst_any => abort(); + case => abort(); }; let gv: regex.inst_groupend; let ge: regex.inst = gv; match (ge) { case let e: regex.inst_groupend => void; - case let a: regex.inst_any => fail(); - case let k: regex.inst_skip => fail(); - case => fail(); + case let a: regex.inst_any => abort(); + case let k: regex.inst_skip => abort(); + case => abort(); }; }; @@ -116,10 +112,10 @@ fn fail() void = { os.exit(signalled + 10); }; let c: regex.inst = (inst_charset { idx = 3, is_positive = true }); match (c) { case let cs: regex.inst_charset => { - if (cs.idx != (3: size)) { fail(); }; - if (!cs.is_positive) { fail(); }; + assert(!(cs.idx != (3: size))); + assert(!(!cs.is_positive)); }; - case => fail(); + case => abort(); }; }; @@ -134,10 +130,10 @@ fn fail() void = { os.exit(signalled + 10); }; }); match (r) { case let rp: regex.inst_repeat => { - if (rp.id != (1: size)) { fail(); }; - if (rp.origin != (4: size)) { fail(); }; + assert(!(rp.id != (1: size))); + assert(!(rp.origin != (4: size))); }; - case => fail(); + case => abort(); }; }; @@ -151,8 +147,8 @@ fn fail() void = { os.exit(signalled + 10); }; end = 3, end_bytesize = 3, }; - if (cap.content.len != 3) { fail(); }; - if (cap.end != (3: size)) { fail(); }; + assert(!(cap.content.len != 3)); + assert(!(cap.end != (3: size))); // regex's insts/charsets ([]inst / []charset) are left empty here: // fold 1 ports no compile() to populate them, an empty `[]` literal @@ -162,8 +158,8 @@ fn fail() void = { os.exit(signalled + 10); }; // slice headers to {0,0,0}; only n_reps is set explicitly. let re: regex.regex; re.n_reps = 0; - if (re.n_reps != (0: size)) { fail(); }; - if (re.insts.len != 0) { fail(); }; + assert(!(re.n_reps != (0: size))); + assert(!(re.insts.len != 0)); regex.finish(&re); }; @@ -179,32 +175,32 @@ fn fail() void = { os.exit(signalled + 10); }; let c: (regex.regex | regex.error | nomem) = regex.compile("abc"); match (c) { case let re: regex.regex => { - if (re.insts.len != 5) { fail(); }; + assert(!(re.insts.len != 5)); match (re.insts[0]) { case let k: regex.inst_skip => void; - case => fail(); + case => abort(); }; match (re.insts[1]) { - case let l: regex.inst_lit => { if ((l: rune) != 'a') { fail(); }; }; - case => fail(); + case let l: regex.inst_lit => { assert(!((l: rune) != 'a')); }; + case => abort(); }; match (re.insts[2]) { - case let l: regex.inst_lit => { if ((l: rune) != 'b') { fail(); }; }; - case => fail(); + case let l: regex.inst_lit => { assert(!((l: rune) != 'b')); }; + case => abort(); }; match (re.insts[3]) { - case let l: regex.inst_lit => { if ((l: rune) != 'c') { fail(); }; }; - case => fail(); + case let l: regex.inst_lit => { assert(!((l: rune) != 'c')); }; + case => abort(); }; match (re.insts[4]) { - case let m: regex.inst_match => { if ((m: bool)) { fail(); }; }; - case => fail(); + case let m: regex.inst_match => { assert(!((m: bool))); }; + case => abort(); }; - if (re.charsets.len != 0) { fail(); }; - if (re.n_reps != (0: size)) { fail(); }; + assert(!(re.charsets.len != 0)); + assert(!(re.n_reps != (0: size))); regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -214,30 +210,30 @@ fn fail() void = { os.exit(signalled + 10); }; let c: (regex.regex | regex.error | nomem) = regex.compile("a.c"); match (c) { case let re: regex.regex => { - if (re.insts.len != 5) { fail(); }; + assert(!(re.insts.len != 5)); match (re.insts[0]) { case let k: regex.inst_skip => void; - case => fail(); + case => abort(); }; match (re.insts[1]) { - case let l: regex.inst_lit => { if ((l: rune) != 'a') { fail(); }; }; - case => fail(); + case let l: regex.inst_lit => { assert(!((l: rune) != 'a')); }; + case => abort(); }; match (re.insts[2]) { case let a: regex.inst_any => void; - case => fail(); + case => abort(); }; match (re.insts[3]) { - case let l: regex.inst_lit => { if ((l: rune) != 'c') { fail(); }; }; - case => fail(); + case let l: regex.inst_lit => { assert(!((l: rune) != 'c')); }; + case => abort(); }; match (re.insts[4]) { - case let m: regex.inst_match => { if ((m: bool)) { fail(); }; }; - case => fail(); + case let m: regex.inst_match => { assert(!((m: bool))); }; + case => abort(); }; regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -247,14 +243,14 @@ fn fail() void = { os.exit(signalled + 10); }; @test fn compile_empty_program() void = { match (regex.compile("")) { case let re: regex.regex => { - if (re.insts.len != 1) { fail(); }; + assert(!(re.insts.len != 1)); match (re.insts[0]) { - case let m: regex.inst_match => { if ((m: bool)) { fail(); }; }; - case => fail(); + case let m: regex.inst_match => { assert(!((m: bool))); }; + case => abort(); }; regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -308,18 +304,18 @@ type texp = struct { matched = false, failed = false, ncaps = 0, nreps = 0 }, ]; - if (len(threads) != len(want)) { fail(); }; + assert(!(len(threads) != len(want))); let i: i32 = 0; for (i < len(want)) { - if (threads[i].pc != want[i].pc) { fail(); }; - if (threads[i].start_idx != want[i].start_idx) { fail(); }; + assert(!(threads[i].pc != want[i].pc)); + assert(!(threads[i].start_idx != want[i].start_idx)); if (threads[i].start_bytesize != want[i].start_bytesize) { - fail(); + abort(); }; - if (threads[i].matched != want[i].matched) { fail(); }; - if (threads[i].failed != want[i].failed) { fail(); }; - if (threads[i].captures.len != want[i].ncaps) { fail(); }; - if (threads[i].rep_counters.len != want[i].nreps) { fail(); }; + assert(!(threads[i].matched != want[i].matched)); + assert(!(threads[i].failed != want[i].failed)); + assert(!(threads[i].captures.len != want[i].ncaps)); + assert(!(threads[i].rep_counters.len != want[i].nreps)); i += 1; }; }; @@ -359,9 +355,9 @@ type nmexp = struct { let i: i32 = 0; for (i < len(rows)) { let r: (void | newmatch | nomem) = nm_probe(rows[i].arg); - if ((r is newmatch) != rows[i].want_nm) { fail(); }; - if ((r is void) != rows[i].want_void) { fail(); }; - if ((r is nomem) != rows[i].want_nomem) { fail(); }; + assert(!((r is newmatch) != rows[i].want_nm)); + assert(!((r is void) != rows[i].want_void)); + assert(!((r is nomem) != rows[i].want_nomem)); i += 1; }; }; @@ -380,15 +376,15 @@ type nmexp = struct { end = 1, end_bytesize = 1, }); regex.result_free(res); - if (len(res) != 1) { fail(); }; - if (res[0].end != (1: size)) { fail(); }; + assert(!(len(res) != 1)); + assert(!(res[0].end != (1: size))); // The zero-header edge: find()'s no-match path returns an empty // result (regex.ha:915-916) the caller still result_free()s. The // bare decl is alias-typed — the #20 dodge above is append-only, // so the alias stays exercised in value position here. let empty: regex.result; regex.result_free(empty); - if (len(empty) != 0) { fail(); }; + assert(!(len(empty) != 0)); }; // strerror (regex.ha:1127) is identity on the boundary text — routed @@ -399,10 +395,10 @@ type nmexp = struct { case let e: regex.error => { if (strings.compare(regex.strerror(e), "Unmatched '('") != 0) { - fail(); + abort(); }; }; - case => fail(); + case => abort(); }; }; @@ -415,7 +411,7 @@ type nmexp = struct { // #38b-unwired, so each value goes through a typed let (the // #19-landed ident source). fn ic_one(v: regex.inst, want: bool) void = { - if (is_consuming_inst(v) != want) { fail(); }; + assert(!(is_consuming_inst(v) != want)); }; @test fn is_consuming_kinds() void = { @@ -460,21 +456,21 @@ fn ic_one(v: regex.inst, want: bool) void = { append(ts, thread { pc = 2, start_idx = 22, ... }); append(ts, thread { pc = 3, start_idx = 33, ... }); delete_thread(1, &ts); - if (len(ts) != 2) { fail(); }; - if (ts[0].pc != (1: size)) { fail(); }; - if (ts[0].start_idx != (11: size)) { fail(); }; - if (ts[0].captures.len != 1) { fail(); }; - if (ts[1].pc != (3: size)) { fail(); }; - if (ts[1].start_idx != (33: size)) { fail(); }; - if (ts[1].captures.len != 0) { fail(); }; + assert(!(len(ts) != 2)); + assert(!(ts[0].pc != (1: size))); + assert(!(ts[0].start_idx != (11: size))); + assert(!(ts[0].captures.len != 1)); + assert(!(ts[1].pc != (3: size))); + assert(!(ts[1].start_idx != (33: size))); + assert(!(ts[1].captures.len != 0)); // boundary rows: delete at the last index, then at index 0 down // to empty — the failed-sweep loop (regex.ha:891-896) deletes at // every position including both ends. delete_thread(1, &ts); - if (len(ts) != 1) { fail(); }; - if (ts[0].pc != (1: size)) { fail(); }; + assert(!(len(ts) != 1)); + assert(!(ts[0].pc != (1: size))); delete_thread(0, &ts); - if (len(ts) != 0) { fail(); }; + assert(!(len(ts) != 0)); }; // add_thread (regex.ha:557-587): same-pc dedup suppression fires only @@ -489,37 +485,37 @@ fn ic_one(v: regex.inst, want: bool) void = { matched = false, failed = true, ... }); // inherit: fresh pc, parent fields copied, rest zeroed let r: (void | nomem) = add_thread(&ts, 0, 7); - if (!(r is void)) { fail(); }; - if (len(ts) != 2) { fail(); }; - if (ts[1].pc != (7: size)) { fail(); }; - if (ts[1].start_idx != (5: size)) { fail(); }; - if (ts[1].start_bytesize != (4: size)) { fail(); }; - if (ts[1].matched) { fail(); }; - if (!ts[1].failed) { fail(); }; - if (ts[1].captures.len != 0) { fail(); }; - if (ts[1].rep_counters.len != 0) { fail(); }; - if (ts[1].root_capture.content.len != 0) { fail(); }; - if (ts[1].root_capture.end != (0: size)) { fail(); }; + assert(!(!(r is void))); + assert(!(len(ts) != 2)); + assert(!(ts[1].pc != (7: size))); + assert(!(ts[1].start_idx != (5: size))); + assert(!(ts[1].start_bytesize != (4: size))); + assert(!(ts[1].matched)); + assert(!(!ts[1].failed)); + assert(!(ts[1].captures.len != 0)); + assert(!(ts[1].rep_counters.len != 0)); + assert(!(ts[1].root_capture.content.len != 0)); + assert(!(ts[1].root_capture.end != (0: size))); // same-pc same-start does NOT suppress (strict <, ha:563-565) let r2: (void | nomem) = add_thread(&ts, 0, 7); - if (!(r2 is void)) { fail(); }; - if (len(ts) != 3) { fail(); }; + assert(!(!(r2 is void))); + assert(!(len(ts) != 3)); // an earlier-started unmatched existing thread DOES suppress let ts2: []thread = []; append(ts2, thread { pc = 0, start_idx = 5, ... }); append(ts2, thread { pc = 7, start_idx = 2, ... }); let r3: (void | nomem) = add_thread(&ts2, 0, 7); - if (!(r3 is void)) { fail(); }; - if (len(ts2) != 2) { fail(); }; + assert(!(!(r3 is void))); + assert(!(len(ts2) != 2)); // a MATCHED existing thread never suppresses let ts3: []thread = []; append(ts3, thread { pc = 0, start_idx = 5, ... }); append(ts3, thread { pc = 7, start_idx = 2, matched = true, ... }); let r4: (void | nomem) = add_thread(&ts3, 0, 7); - if (!(r4 is void)) { fail(); }; - if (len(ts3) != 3) { fail(); }; - if (ts3[2].pc != (7: size)) { fail(); }; - if (ts3[2].start_idx != (5: size)) { fail(); }; + assert(!(!(r4 is void))); + assert(!(len(ts3) != 3)); + assert(!(ts3[2].pc != (7: size))); + assert(!(ts3[2].start_idx != (5: size))); }; // add_thread dup (regex.ha:568-573): the child carries a COPY of the @@ -544,35 +540,35 @@ fn ic_one(v: regex.inst, want: bool) void = { append(ts, thread { pc = 0, start_idx = 1, captures = caps, rep_counters = reps, ... }); let r: (void | nomem) = add_thread(&ts, 0, 9); - if (!(r is void)) { fail(); }; - if (len(ts) != 2) { fail(); }; + assert(!(!(r is void))); + assert(!(len(ts) != 2)); // dup carried the parent's values - if (ts[1].captures.len != 2) { fail(); }; - if (strings.compare(ts[1].captures[0].content, "ab") != 0) { fail(); }; - if (ts[1].captures[0].start != (1: size)) { fail(); }; - if (ts[1].captures[1].end != (4: size)) { fail(); }; - if (ts[1].rep_counters.len != 2) { fail(); }; - if (ts[1].rep_counters[0] != (5: size)) { fail(); }; - if (ts[1].rep_counters[1] != (6: size)) { fail(); }; + assert(!(ts[1].captures.len != 2)); + assert(!(strings.compare(ts[1].captures[0].content, "ab") != 0)); + assert(!(ts[1].captures[0].start != (1: size))); + assert(!(ts[1].captures[1].end != (4: size))); + assert(!(ts[1].rep_counters.len != 2)); + assert(!(ts[1].rep_counters[0] != (5: size))); + assert(!(ts[1].rep_counters[1] != (6: size))); // independence, parent → child: mutate the parent post-add ts[0].captures[0].start = 100; ts[0].captures[0].content = "zz"; ts[0].rep_counters[0] = 77; - if (ts[1].captures[0].start != (1: size)) { fail(); }; - if (strings.compare(ts[1].captures[0].content, "ab") != 0) { fail(); }; - if (ts[1].rep_counters[0] != (5: size)) { fail(); }; + assert(!(ts[1].captures[0].start != (1: size))); + assert(!(strings.compare(ts[1].captures[0].content, "ab") != 0)); + assert(!(ts[1].rep_counters[0] != (5: size))); // independence, child → parent ts[1].captures[1].end = 200; ts[1].rep_counters[1] = 88; - if (ts[0].captures[1].end != (4: size)) { fail(); }; - if (ts[0].rep_counters[1] != (6: size)) { fail(); }; + assert(!(ts[0].captures[1].end != (4: size))); + assert(!(ts[0].rep_counters[1] != (6: size))); // empty parent → empty dup let ts2: []thread = []; append(ts2, thread { pc = 0, ... }); let r2: (void | nomem) = add_thread(&ts2, 0, 3); - if (!(r2 is void)) { fail(); }; - if (ts2[1].captures.len != 0) { fail(); }; - if (ts2[1].rep_counters.len != 0) { fail(); }; + assert(!(!(r2 is void))); + assert(!(ts2[1].captures.len != 0)); + assert(!(ts2[1].rep_counters.len != 0)); }; // run_thread (regex.ha:589-742) driven directly over compile("ab")'s @@ -594,24 +590,24 @@ fn ic_one(v: regex.inst, want: bool) void = { let ts: []thread = []; append(ts, thread { pc = 0, ... }); let r1: (void | newmatch | nomem) = run_thread(0, &re, "ab", &ts, ra, 0, 0); - if (!(r1 is void)) { fail(); }; - if (len(ts) != 2) { fail(); }; - if (ts[0].pc != (0: size)) { fail(); }; - if (ts[1].pc != (1: size)) { fail(); }; - if (ts[1].failed) { fail(); }; + assert(!(!(r1 is void))); + assert(!(len(ts) != 2)); + assert(!(ts[0].pc != (0: size))); + assert(!(ts[1].pc != (1: size))); + assert(!(ts[1].failed)); // lit match advances pc past 'a' let r2: (void | newmatch | nomem) = run_thread(1, &re, "ab", &ts, ra, 0, 0); - if (!(r2 is void)) { fail(); }; - if (ts[1].pc != (2: size)) { fail(); }; - if (ts[1].failed) { fail(); }; + assert(!(!(r2 is void))); + assert(!(ts[1].pc != (2: size))); + assert(!(ts[1].failed)); // lit mismatch fails the thread; pc steps anyway (ha:741) let rx: (rune | io.eof) = 'x'; let r3: (void | newmatch | nomem) = run_thread(1, &re, "ab", &ts, rx, 1, 1); - if (!(r3 is void)) { fail(); }; - if (!ts[1].failed) { fail(); }; - if (ts[1].pc != (3: size)) { fail(); }; + assert(!(!(r3 is void))); + assert(!(!ts[1].failed)); + assert(!(ts[1].pc != (3: size))); // EOF on a consuming pc fails the thread before pc steps let ev: io.eof; @@ -619,29 +615,29 @@ fn ic_one(v: regex.inst, want: bool) void = { let ts2: []thread = []; append(ts2, thread { pc = 1, ... }); let r4: (void | newmatch | nomem) = run_thread(0, &re, "ab", &ts2, reof, 2, 2); - if (!(r4 is void)) { fail(); }; - if (!ts2[0].failed) { fail(); }; - if (ts2[0].pc != (1: size)) { fail(); }; + assert(!(!(r4 is void))); + assert(!(!ts2[0].failed)); + assert(!(ts2[0].pc != (1: size))); // match arm: root_capture spans start_bytesize..str_bytesize, // matched set, newmatch returned let ts3: []thread = []; append(ts3, thread { pc = 3, ... }); let r5: (void | newmatch | nomem) = run_thread(0, &re, "ab", &ts3, reof, 2, 2); - if (!(r5 is newmatch)) { fail(); }; - if (!ts3[0].matched) { fail(); }; - if (ts3[0].failed) { fail(); }; - if (ts3[0].root_capture.start != (0: size)) { fail(); }; - if (ts3[0].root_capture.start_bytesize != (0: size)) { fail(); }; - if (ts3[0].root_capture.end != (2: size)) { fail(); }; - if (ts3[0].root_capture.end_bytesize != (2: size)) { fail(); }; - if (strings.compare(ts3[0].root_capture.content, "ab") != 0) { fail(); }; + assert(!(!(r5 is newmatch))); + assert(!(!ts3[0].matched)); + assert(!(ts3[0].failed)); + assert(!(ts3[0].root_capture.start != (0: size))); + assert(!(ts3[0].root_capture.start_bytesize != (0: size))); + assert(!(ts3[0].root_capture.end != (2: size))); + assert(!(ts3[0].root_capture.end_bytesize != (2: size))); + assert(!(strings.compare(ts3[0].root_capture.content, "ab") != 0)); // an already-matched thread is inert (ha:599-601): void // return, state untouched let r6: (void | newmatch | nomem) = run_thread(0, &re, "ab", &ts3, ra, 3, 3); - if (!(r6 is void)) { fail(); }; - if (ts3[0].root_capture.end != (2: size)) { fail(); }; + assert(!(!(r6 is void))); + assert(!(ts3[0].root_capture.end != (2: size))); // idx/bytesize split: every all-ASCII row has idx == // bytesize, so a port swapping start/start_bytesize (or @@ -652,15 +648,15 @@ fn ic_one(v: regex.inst, want: bool) void = { let ts4: []thread = []; append(ts4, thread { pc = 3, start_idx = 1, start_bytesize = 2, ... }); let r7: (void | newmatch | nomem) = run_thread(0, &re, "ßab", &ts4, reof, 3, 4); - if (!(r7 is newmatch)) { fail(); }; - if (ts4[0].root_capture.start != (1: size)) { fail(); }; - if (ts4[0].root_capture.start_bytesize != (2: size)) { fail(); }; - if (ts4[0].root_capture.end != (3: size)) { fail(); }; - if (ts4[0].root_capture.end_bytesize != (4: size)) { fail(); }; - if (strings.compare(ts4[0].root_capture.content, "ab") != 0) { fail(); }; + assert(!(!(r7 is newmatch))); + assert(!(ts4[0].root_capture.start != (1: size))); + assert(!(ts4[0].root_capture.start_bytesize != (2: size))); + assert(!(ts4[0].root_capture.end != (3: size))); + assert(!(ts4[0].root_capture.end_bytesize != (4: size))); + assert(!(strings.compare(ts4[0].root_capture.content, "ab") != 0)); regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -679,19 +675,19 @@ fn ic_one(v: regex.inst, want: bool) void = { let ts: []thread = []; append(ts, thread { pc = 0, ... }); let r1: (void | newmatch | nomem) = run_thread(0, &re, "ab", &ts, ra, 0, 0); - if (!(r1 is void)) { fail(); }; - if (!ts[0].failed) { fail(); }; - if (ts[0].matched) { fail(); }; + assert(!(!(r1 is void))); + assert(!(!ts[0].failed)); + assert(!(ts[0].matched)); let ev: io.eof; let reof: (rune | io.eof) = ev; let ts2: []thread = []; append(ts2, thread { pc = 0, ... }); let r2: (void | newmatch | nomem) = run_thread(0, &re, "", &ts2, reof, 0, 0); - if (!(r2 is newmatch)) { fail(); }; - if (!ts2[0].matched) { fail(); }; - if (ts2[0].root_capture.content.len != 0) { fail(); }; - if (ts2[0].root_capture.end != (0: size)) { fail(); }; + assert(!(!(r2 is newmatch))); + assert(!(!ts2[0].matched)); + assert(!(ts2[0].root_capture.content.len != 0)); + assert(!(ts2[0].root_capture.end != (0: size))); }; // search (regex.ha:746-898) driven DIRECTLY (private fn, package-regex @@ -757,21 +753,21 @@ type scase = struct { memio.fixed(strings.toutf8(inp)); let r: (void | []capture | nomem) = search(&re, inp, &strm.vt, rows[i].nc); - if (!(r is []capture)) { fail(); }; + assert(!(!(r is []capture))); let caps: []capture = r as []capture; - if (len(caps) != 1) { fail(); }; - if (caps[0].start != rows[i].start) { fail(); }; - if (caps[0].start_bytesize != rows[i].sb) { fail(); }; - if (caps[0].end != rows[i].end) { fail(); }; - if (caps[0].end_bytesize != rows[i].eb) { fail(); }; + assert(!(len(caps) != 1)); + assert(!(caps[0].start != rows[i].start)); + assert(!(caps[0].start_bytesize != rows[i].sb)); + assert(!(caps[0].end != rows[i].end)); + assert(!(caps[0].end_bytesize != rows[i].eb)); let wc: str = rows[i].content; if (strings.compare(caps[0].content, wc) != 0) { - fail(); + abort(); }; regex.result_free(caps); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -786,13 +782,13 @@ type scase = struct { let strm: memio.stream = memio.fixed(strings.toutf8("xab")); let r: (void | []capture | nomem) = search(&re, "xab", &strm.vt, false); - if (!(r is []capture)) { fail(); }; + assert(!(!(r is []capture))); let caps: []capture = r as []capture; - if (len(caps) != 0) { fail(); }; + assert(!(len(caps) != 0)); regex.result_free(caps); regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -806,14 +802,14 @@ type scase = struct { let strm: memio.stream = memio.fixed(strings.toutf8("xyz")); let r: (void | []capture | nomem) = search(&re, "xyz", &strm.vt, true); - if (!(r is void)) { fail(); }; + assert(!(!(r is void))); let strm2: memio.stream = memio.fixed(strings.toutf8("a")); let r2: (void | []capture | nomem) = search(&re, "a", &strm2.vt, true); - if (!(r2 is void)) { fail(); }; + assert(!(!(r2 is void))); regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -844,11 +840,11 @@ type tcase = struct { match (c) { case let re: regex.regex => { let tr: (bool | nomem) = regex.test(&re, inp); - if (!(tr is bool)) { fail(); }; - if ((tr as bool) != rows[i].want) { fail(); }; + assert(!(!(tr is bool))); + assert(!((tr as bool) != rows[i].want)); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -894,35 +890,35 @@ type fcase = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, inp); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; if (rows[i].matches) { - if (len(res) != 1) { fail(); }; - if (res[0].start != rows[i].start) { fail(); }; + assert(!(len(res) != 1)); + assert(!(res[0].start != rows[i].start)); if (res[0].start_bytesize != rows[i].sb) { - fail(); + abort(); }; - if (res[0].end != rows[i].end) { fail(); }; + assert(!(res[0].end != rows[i].end)); if (res[0].end_bytesize != rows[i].eb) { - fail(); + abort(); }; let wc: str = rows[i].content; if (strings.compare(res[0].content, wc) != 0) { - fail(); + abort(); }; } else { - if (len(res) != 0) { fail(); }; + assert(!(len(res) != 0)); }; // the two surfaces share search; pin their // agreement so an arm-swap in either D13 match // can't hide behind a one-sided table let tr: (bool | nomem) = regex.test(&re, inp); - if (!(tr is bool)) { fail(); }; - if ((tr as bool) != (len(res) != 0)) { fail(); }; + assert(!(!(tr is bool))); + assert(!((tr as bool) != (len(res) != 0))); regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -967,22 +963,22 @@ type facase = struct { case let re: regex.regex => { let fr: ([]regex.result | nomem) = regex.findall(&re, inp); - if (!(fr is []regex.result)) { fail(); }; + assert(!(!(fr is []regex.result))); let results: []regex.result = fr as []regex.result; - if (len(results) != rows[i].tcnt) { fail(); }; + assert(!(len(results) != rows[i].tcnt)); let k: i32 = 0; for (k < rows[i].tcnt) { let want: str = targets[rows[i].toff + k]; if (strings.compare(results[k][0].content, want) != 0) { - fail(); + abort(); }; k += 1; }; regex.result_freeall(results); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1059,30 +1055,30 @@ type fdexp = struct { case let re: regex.regex => { let fr: ([]regex.result | nomem) = regex.findall(&re, inp); - if (!(fr is []regex.result)) { fail(); }; + assert(!(!(fr is []regex.result))); let results: []regex.result = fr as []regex.result; - if (len(results) != rows[i].ecnt) { fail(); }; + assert(!(len(results) != rows[i].ecnt)); let k: i32 = 0; for (k < rows[i].ecnt) { let w: fdexp = exp[rows[i].eoff + k]; - if (results[k][0].start != w.start) { fail(); }; + assert(!(results[k][0].start != w.start)); if (results[k][0].start_bytesize != w.sb) { - fail(); + abort(); }; - if (results[k][0].end != w.end) { fail(); }; + assert(!(results[k][0].end != w.end)); if (results[k][0].end_bytesize != w.eb) { - fail(); + abort(); }; if (strings.compare(results[k][0].content, w.content) != 0) { - fail(); + abort(); }; k += 1; }; regex.result_freeall(results); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1159,18 +1155,18 @@ type pgmcase = struct { let c: (regex.regex | regex.error | nomem) = regex.compile(ex); match (c) { case let re: regex.regex => { - if (re.insts.len != rows[i].scnt) { fail(); }; + assert(!(re.insts.len != rows[i].scnt)); let k: i32 = 0; for (k < rows[i].scnt) { if (instsig(re.insts[k]) != sigs[rows[i].soff + k]) { - fail(); + abort(); }; k += 1; }; regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1211,9 +1207,9 @@ type cerow = struct { match (regex.compile(p)) { case let e: regex.error => { let w: str = rows[i].want; - if (strings.compare((e: str), w) != 0) { fail(); }; + assert(!(strings.compare((e: str), w) != 0)); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1229,16 +1225,16 @@ type cerow = struct { match (find_last_groupstart(insts)) { case let e: regex.error => { if (strings.compare((e: str), "Unmatched ')'") != 0) { - fail(); + abort(); }; }; - case => fail(); + case => abort(); }; append(insts, ((1: size): regex.inst_groupstart)); append(insts, ('b': regex.inst_lit)); match (find_last_groupstart(insts)) { - case let sz: size => { if (sz != 1) { fail(); }; }; - case => fail(); + case let sz: size => { assert(!(sz != 1)); }; + case => abort(); }; }; @@ -1252,10 +1248,10 @@ type cerow = struct { append(insts, ((5: size): regex.inst_split)); append(insts, ((7: size): regex.inst_jump)); shift(insts[1:]); - if (instsig(insts[0]) != 5003) { fail(); }; - if (instsig(insts[1]) != 1097) { fail(); }; - if (instsig(insts[2]) != 4006) { fail(); }; - if (instsig(insts[3]) != 5008) { fail(); }; + assert(!(instsig(insts[0]) != 5003)); + assert(!(instsig(insts[1]) != 1097)); + assert(!(instsig(insts[2]) != 4006)); + assert(!(instsig(insts[3]) != 5008)); }; // fold-3 find/test rows — the group-free subset of Hare's own table @@ -1354,32 +1350,32 @@ type cerow = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, inp); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; if (rows[i].matches) { - if (len(res) != 1) { fail(); }; - if (res[0].start != rows[i].start) { fail(); }; + assert(!(len(res) != 1)); + assert(!(res[0].start != rows[i].start)); if (res[0].start_bytesize != rows[i].sb) { - fail(); + abort(); }; - if (res[0].end != rows[i].end) { fail(); }; + assert(!(res[0].end != rows[i].end)); if (res[0].end_bytesize != rows[i].eb) { - fail(); + abort(); }; let wc: str = rows[i].content; if (strings.compare(res[0].content, wc) != 0) { - fail(); + abort(); }; } else { - if (len(res) != 0) { fail(); }; + assert(!(len(res) != 0)); }; let tr: (bool | nomem) = regex.test(&re, inp); - if (!(tr is bool)) { fail(); }; - if ((tr as bool) != (len(res) != 0)) { fail(); }; + assert(!(!(tr is bool))); + assert(!((tr as bool) != (len(res) != 0))); regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1418,18 +1414,18 @@ type cerow = struct { let c: (regex.regex | regex.error | nomem) = regex.compile(ex); match (c) { case let re: regex.regex => { - if (re.insts.len != rows[i].scnt) { fail(); }; + assert(!(re.insts.len != rows[i].scnt)); let k: i32 = 0; for (k < rows[i].scnt) { if (instsig(re.insts[k]) != sigs[rows[i].soff + k]) { - fail(); + abort(); }; k += 1; }; regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1495,21 +1491,21 @@ type cscase = struct { let c: (regex.regex | regex.error | nomem) = regex.compile(ex); match (c) { case let re: regex.regex => { - if (re.charsets.len != 1) { fail(); }; + assert(!(re.charsets.len != 1)); let cs0: [](charset_lit_item | charset_range_item | charset_class_item) = re.charsets[0]; - if ((len(cs0): i32) != rows[i].ecnt) { fail(); }; + assert(!((len(cs0): i32) != rows[i].ecnt)); let k: i32 = 0; for (k < rows[i].ecnt) { if (cssig(cs0, (k: size)) != exp[rows[i].eoff + k]) { - fail(); + abort(); }; k += 1; }; regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1535,9 +1531,9 @@ type cscase = struct { match (regex.compile(p)) { case let e: regex.error => { let w: str = rows[i].want; - if (strings.compare((e: str), w) != 0) { fail(); }; + assert(!(strings.compare((e: str), w) != 0)); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1678,32 +1674,32 @@ type cscase = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, inp); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; if (rows[i].matches) { - if (len(res) != 1) { fail(); }; - if (res[0].start != rows[i].start) { fail(); }; + assert(!(len(res) != 1)); + assert(!(res[0].start != rows[i].start)); if (res[0].start_bytesize != rows[i].sb) { - fail(); + abort(); }; - if (res[0].end != rows[i].end) { fail(); }; + assert(!(res[0].end != rows[i].end)); if (res[0].end_bytesize != rows[i].eb) { - fail(); + abort(); }; let wc: str = rows[i].content; if (strings.compare(res[0].content, wc) != 0) { - fail(); + abort(); }; } else { - if (len(res) != 0) { fail(); }; + assert(!(len(res) != 0)); }; let tr: (bool | nomem) = regex.test(&re, inp); - if (!(tr is bool)) { fail(); }; - if ((tr as bool) != (len(res) != 0)) { fail(); }; + assert(!(!(tr is bool))); + assert(!((tr as bool) != (len(res) != 0))); regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1717,23 +1713,23 @@ type cscase = struct { case let re: regex.regex => { let fr: ([]regex.result | nomem) = regex.findall(&re, "xxabyyba"); - if (!(fr is []regex.result)) { fail(); }; + assert(!(!(fr is []regex.result))); let results: []regex.result = fr as []regex.result; - if (len(results) != 2) { fail(); }; - if (results[0][0].start != (2: size)) { fail(); }; - if (results[0][0].end != (4: size)) { fail(); }; + assert(!(len(results) != 2)); + assert(!(results[0][0].start != (2: size))); + assert(!(results[0][0].end != (4: size))); if (strings.compare(results[0][0].content, "ab") != 0) { - fail(); + abort(); }; - if (results[1][0].start != (6: size)) { fail(); }; - if (results[1][0].end != (8: size)) { fail(); }; + assert(!(results[1][0].start != (6: size))); + assert(!(results[1][0].end != (8: size))); if (strings.compare(results[1][0].content, "ba") != 0) { - fail(); + abort(); }; regex.result_freeall(results); regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -1770,9 +1766,9 @@ type cscase = struct { match (regex.compile(p)) { case let e: regex.error => { let w: str = rows[i].want; - if (strings.compare((e: str), w) != 0) { fail(); }; + assert(!(strings.compare((e: str), w) != 0)); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -1800,19 +1796,19 @@ type cscase = struct { let ts: []thread = []; append(ts, thread { pc = 0, ... }); let r1: (void | newmatch | nomem) = run_thread(0, &re, "ab", &ts, ra, 2, 3); - if (!(r1 is void)) { fail(); }; - if (ts[0].captures.len != 2) { fail(); }; + assert(!(!(r1 is void))); + assert(!(ts[0].captures.len != 2)); // the fill element below idx is zeroed - if (ts[0].captures[0].end != (0: size)) { fail(); }; - if (ts[0].captures[0].content.len != 0) { fail(); }; + assert(!(ts[0].captures[0].end != (0: size))); + assert(!(ts[0].captures[0].content.len != 0)); // the opened group: start stamped, end still the open sentinel - if (ts[0].captures[1].start != (2: size)) { fail(); }; - if (ts[0].captures[1].start_bytesize != (3: size)) { fail(); }; - if (ts[0].captures[1].end != types.SIZE_MAX) { fail(); }; - if (ts[0].captures[1].end_bytesize != types.SIZE_MAX) { fail(); }; + assert(!(ts[0].captures[1].start != (2: size))); + assert(!(ts[0].captures[1].start_bytesize != (3: size))); + assert(!(ts[0].captures[1].end != types.SIZE_MAX)); + assert(!(ts[0].captures[1].end_bytesize != types.SIZE_MAX)); // groupstart is non-consuming: pc stepped through it, then the // lit consumed - if (ts[0].pc != (2: size)) { fail(); }; + assert(!(ts[0].pc != (2: size))); // groupend (ha:653-668): two open groups — the INNERMOST // (highest index) closes first; back-to-back groupends close @@ -1837,14 +1833,14 @@ type cscase = struct { append(ts2, thread { pc = 0, captures = caps, ... }); let rx: (rune | io.eof) = 'x'; let r2: (void | newmatch | nomem) = run_thread(0, &re2, "abcd", &ts2, rx, 3, 4); - if (!(r2 is void)) { fail(); }; - if (ts2[0].captures[1].end != (3: size)) { fail(); }; - if (ts2[0].captures[1].end_bytesize != (4: size)) { fail(); }; - if (strings.compare(ts2[0].captures[1].content, "cd") != 0) { fail(); }; - if (ts2[0].captures[0].end != (3: size)) { fail(); }; - if (ts2[0].captures[0].end_bytesize != (4: size)) { fail(); }; - if (strings.compare(ts2[0].captures[0].content, "bcd") != 0) { fail(); }; - if (ts2[0].pc != (3: size)) { fail(); }; + assert(!(!(r2 is void))); + assert(!(ts2[0].captures[1].end != (3: size))); + assert(!(ts2[0].captures[1].end_bytesize != (4: size))); + assert(!(strings.compare(ts2[0].captures[1].content, "cd") != 0)); + assert(!(ts2[0].captures[0].end != (3: size))); + assert(!(ts2[0].captures[0].end_bytesize != (4: size))); + assert(!(strings.compare(ts2[0].captures[0].content, "bcd") != 0)); + assert(!(ts2[0].pc != (3: size))); // closed-group re-entry: groupstart over an already-CLOSED idx // passes the ha:642 assert (end != SIZE_MAX) and re-opens fresh @@ -1861,11 +1857,11 @@ type cscase = struct { let ts3: []thread = []; append(ts3, thread { pc = 0, captures = caps3, ... }); let r3: (void | newmatch | nomem) = run_thread(0, &re3, "aba", &ts3, ra, 2, 2); - if (!(r3 is void)) { fail(); }; - if (ts3[0].captures.len != 1) { fail(); }; - if (ts3[0].captures[0].start != (2: size)) { fail(); }; - if (ts3[0].captures[0].end != types.SIZE_MAX) { fail(); }; - if (ts3[0].captures[0].content.len != 0) { fail(); }; + assert(!(!(r3 is void))); + assert(!(ts3[0].captures.len != 1)); + assert(!(ts3[0].captures[0].start != (2: size))); + assert(!(ts3[0].captures[0].end != types.SIZE_MAX)); + assert(!(ts3[0].captures[0].content.len != 0)); }; // fold-5a find/test rows — the group rows of Hare's own table: @@ -2012,32 +2008,32 @@ type f5case = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, inp); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; if (rows[i].matches) { - if ((len(res): i32) != rows[i].ncaps) { fail(); }; - if (res[0].start != rows[i].start) { fail(); }; + assert(!((len(res): i32) != rows[i].ncaps)); + assert(!(res[0].start != rows[i].start)); if (res[0].start_bytesize != rows[i].sb) { - fail(); + abort(); }; - if (res[0].end != rows[i].end) { fail(); }; + assert(!(res[0].end != rows[i].end)); if (res[0].end_bytesize != rows[i].eb) { - fail(); + abort(); }; let wc: str = rows[i].content; if (strings.compare(res[0].content, wc) != 0) { - fail(); + abort(); }; } else { - if (len(res) != 0) { fail(); }; + assert(!(len(res) != 0)); }; let tr: (bool | nomem) = regex.test(&re, inp); - if (!(tr is bool)) { fail(); }; - if ((tr as bool) != (len(res) != 0)) { fail(); }; + assert(!(!(tr is bool))); + assert(!((tr as bool) != (len(res) != 0))); regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -2051,16 +2047,16 @@ type f5case = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, "ab"); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; - if (len(res) != 2) { fail(); }; - if (res[0].start != (0: size)) { fail(); }; - if (res[0].end != (1: size)) { fail(); }; - if (strings.compare(res[0].content, "a") != 0) { fail(); }; + assert(!(len(res) != 2)); + assert(!(res[0].start != (0: size))); + assert(!(res[0].end != (1: size))); + assert(!(strings.compare(res[0].content, "a") != 0)); regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -2097,22 +2093,22 @@ type smcase = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, inp); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; - if ((len(res): i32) != rows[i].tcnt) { fail(); }; + assert(!((len(res): i32) != rows[i].tcnt)); let k: i32 = 0; for (k < rows[i].tcnt) { let want: str = targets[rows[i].toff + k]; if (strings.compare(res[k].content, want) != 0) { - fail(); + abort(); }; k += 1; }; regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -2178,23 +2174,23 @@ type prrow = struct { let r: (repparts | error) = parse_repetition(rows[i].input); match (r) { case let t: repparts => { - if (rows[i].err.len > 0) { fail(); }; + assert(!(rows[i].err.len > 0)); // .min is always size after a successful parse // (ha:523-525 — empty min defaults to 0) - if (!(t.min is size)) { fail(); }; - if (t.min as size != rows[i].minv) { fail(); }; + assert(!(!(t.min is size))); + assert(!(t.min as size != rows[i].minv)); if (rows[i].max_void) { - if (!(t.max is void)) { fail(); }; + assert(!(!(t.max is void))); } else { - if (!(t.max is size)) { fail(); }; - if (t.max as size != rows[i].maxv) { fail(); }; + assert(!(!(t.max is size))); + assert(!(t.max as size != rows[i].maxv)); }; - if (t.replen != rows[i].replen) { fail(); }; + assert(!(t.replen != rows[i].replen)); }; case let e: regex.error => { - if (rows[i].err.len == 0) { fail(); }; + assert(!(rows[i].err.len == 0)); if (strings.compare((e: str), rows[i].err) != 0) { - fail(); + abort(); }; }; }; @@ -2226,9 +2222,9 @@ type prrow = struct { match (regex.compile(p)) { case let e: regex.error => { let w: str = rows[i].want; - if (strings.compare((e: str), w) != 0) { fail(); }; + assert(!(strings.compare((e: str), w) != 0)); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -2359,32 +2355,32 @@ type prrow = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, inp); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; if (rows[i].matches) { - if ((len(res): i32) != rows[i].ncaps) { fail(); }; - if (res[0].start != rows[i].start) { fail(); }; + assert(!((len(res): i32) != rows[i].ncaps)); + assert(!(res[0].start != rows[i].start)); if (res[0].start_bytesize != rows[i].sb) { - fail(); + abort(); }; - if (res[0].end != rows[i].end) { fail(); }; + assert(!(res[0].end != rows[i].end)); if (res[0].end_bytesize != rows[i].eb) { - fail(); + abort(); }; let wc: str = rows[i].content; if (strings.compare(res[0].content, wc) != 0) { - fail(); + abort(); }; } else { - if (len(res) != 0) { fail(); }; + assert(!(len(res) != 0)); }; let tr: (bool | nomem) = regex.test(&re, inp); - if (!(tr is bool)) { fail(); }; - if ((tr as bool) != (len(res) != 0)) { fail(); }; + assert(!(!(tr is bool))); + assert(!((tr as bool) != (len(res) != 0))); regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -2408,22 +2404,22 @@ type prrow = struct { case let re: regex.regex => { let fr: ([]regex.result | nomem) = regex.findall(&re, inp); - if (!(fr is []regex.result)) { fail(); }; + assert(!(!(fr is []regex.result))); let results: []regex.result = fr as []regex.result; - if (len(results) != rows[i].tcnt) { fail(); }; + assert(!(len(results) != rows[i].tcnt)); let k: i32 = 0; for (k < rows[i].tcnt) { let want: str = targets[rows[i].toff + k]; if (strings.compare(results[k][0].content, want) != 0) { - fail(); + abort(); }; k += 1; }; regex.result_freeall(results); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -2444,9 +2440,9 @@ type prrow = struct { match (regex.compile(p)) { case let e: regex.error => { let w: str = rows[i].want; - if (strings.compare((e: str), w) != 0) { fail(); }; + assert(!(strings.compare((e: str), w) != 0)); }; - case => fail(); + case => abort(); }; i += 1; }; @@ -2460,14 +2456,14 @@ type prrow = struct { let c: (regex.regex | regex.error | nomem) = regex.compile("[[:digit:]]"); match (c) { case let re: regex.regex => { - if (re.charsets.len != 1) { fail(); }; + assert(!(re.charsets.len != 1)); let cs0: [](charset_lit_item | charset_range_item | charset_class_item) = re.charsets[0]; - if ((len(cs0): i32) != 1) { fail(); }; - if (cssig(cs0, 0) != -2) { fail(); }; + assert(!((len(cs0): i32) != 1)); + assert(!(cssig(cs0, 0) != -2)); regex.finish(&re); }; - case => fail(); + case => abort(); }; }; @@ -2542,85 +2538,85 @@ type prrow = struct { match (c) { case let re: regex.regex => { let fr: (regex.result | nomem) = regex.find(&re, inp); - if (!(fr is regex.result)) { fail(); }; + assert(!(!(fr is regex.result))); let res: regex.result = fr as regex.result; if (rows[i].matches) { - if (len(res) != 1) { fail(); }; - if (res[0].start != rows[i].start) { fail(); }; + assert(!(len(res) != 1)); + assert(!(res[0].start != rows[i].start)); if (res[0].start_bytesize != rows[i].sb) { - fail(); + abort(); }; - if (res[0].end != rows[i].end) { fail(); }; + assert(!(res[0].end != rows[i].end)); if (res[0].end_bytesize != rows[i].eb) { - fail(); + abort(); }; let wc: str = rows[i].content; if (strings.compare(res[0].content, wc) != 0) { - fail(); + abort(); }; } else { - if (len(res) != 0) { fail(); }; + assert(!(len(res) != 0)); }; let tr: (bool | nomem) = regex.test(&re, inp); - if (!(tr is bool)) { fail(); }; - if ((tr as bool) != (len(res) != 0)) { fail(); }; + assert(!(!(tr is bool))); + assert(!((tr as bool) != (len(res) != 0))); regex.result_free(res); regex.finish(&re); }; - case => fail(); + case => abort(); }; i += 1; }; }; export fn main() i32 = { - signalled = 1; lit_and_match(); - signalled = 2; size_aliases_distinct(); - signalled = 3; void_aliases_distinct(); - signalled = 4; charset_payload(); - signalled = 5; repeat_payload(); - signalled = 6; struct_shapes_and_finish(); - signalled = 7; compile_literal_program(); - signalled = 8; compile_any_program(); - signalled = 9; compile_empty_program(); - signalled = 11; thread_shape(); - signalled = 12; newmatch_discriminates(); - signalled = 13; result_free_noop(); - signalled = 14; strerror_identity(); - signalled = 15; is_consuming_kinds(); - signalled = 16; delete_thread_middle(); - signalled = 17; add_thread_dedup_inherit(); - signalled = 18; run_thread_literal_program(); - signalled = 19; run_thread_anchored_route(); - signalled = 20; search_matches(); - signalled = 21; search_early_exit(); - signalled = 22; search_no_match(); - signalled = 23; test_matches(); - signalled = 24; find_cases(); - signalled = 25; findall_content(); - signalled = 26; findall_fields(); - signalled = 27; fold3_programs(); - signalled = 28; fold3_compile_errors(); - signalled = 29; find_last_groupstart_cases(); - signalled = 30; shift_direct(); - signalled = 31; fold3_find_cases(); - signalled = 32; fold4_programs(); - signalled = 33; fold4_charsets(); - signalled = 34; fold4_compile_errors(); - signalled = 35; fold4_find_cases(); - signalled = 36; fold4_findall(); - signalled = 37; add_thread_dup_independence(); - signalled = 38; fold5_compile_errors(); - signalled = 39; run_thread_group_arms(); - signalled = 40; fold5_find_cases(); - signalled = 41; fold5_optional_group(); - signalled = 42; fold5_submatches(); - signalled = 43; parse_repetition_cases(); - signalled = 44; fold5b_compile_errors(); - signalled = 45; fold5b_find_cases(); - signalled = 46; fold5b_findall(); - signalled = 47; fold6_compile_errors(); - signalled = 48; fold6_charsets(); - signalled = 49; fold6_find_cases(); + lit_and_match(); + size_aliases_distinct(); + void_aliases_distinct(); + charset_payload(); + repeat_payload(); + struct_shapes_and_finish(); + compile_literal_program(); + compile_any_program(); + compile_empty_program(); + thread_shape(); + newmatch_discriminates(); + result_free_noop(); + strerror_identity(); + is_consuming_kinds(); + delete_thread_middle(); + add_thread_dedup_inherit(); + run_thread_literal_program(); + run_thread_anchored_route(); + search_matches(); + search_early_exit(); + search_no_match(); + test_matches(); + find_cases(); + findall_content(); + findall_fields(); + fold3_programs(); + fold3_compile_errors(); + find_last_groupstart_cases(); + shift_direct(); + fold3_find_cases(); + fold4_programs(); + fold4_charsets(); + fold4_compile_errors(); + fold4_find_cases(); + fold4_findall(); + add_thread_dup_independence(); + fold5_compile_errors(); + run_thread_group_arms(); + fold5_find_cases(); + fold5_optional_group(); + fold5_submatches(); + parse_repetition_cases(); + fold5b_compile_errors(); + fold5b_find_cases(); + fold5b_findall(); + fold6_compile_errors(); + fold6_charsets(); + fold6_find_cases(); return 0; }; diff --git a/lib/temp/temptest.ww b/lib/temp/temptest.ww index b6ee02c9..8927e81f 100644 --- a/lib/temp/temptest.ww +++ b/lib/temp/temptest.ww @@ -18,19 +18,6 @@ package temp_test; import os; import temp; -// Direct exit(2) binding rather than mixing `use io;` and `use os;` — -// they share read/write/close names under the driver's flat-scope -// concat (task #7). We don't need lib/io here at all (raw fd ops -// via os.read/os.write/os.close suffice), but the binding shape -// mirrors memio/getopt for parity. -fn doexit(code: i32) void = { os.exit(code); }; - -// signalled — bumped by main before each test so a failing exit -// code pinpoints the offending case. -let signalled: i32 = 0; - -fn fail() void = { doexit(signalled + 10); }; - fn streq(a: str, b: str) bool = { if (a.len != b.len) { return false; }; let i: i32 = 0; @@ -58,16 +45,16 @@ fn streq(a: str, b: str) bool = { let p: str; match (temp.named(&fd, &p, "/tmp", temp.mode.RDWR, 384i32)) { // 0o600 case void => {}; - case let e: os.oserror => fail(); + case let e: os.oserror => abort(); }; - if (fd < 0) { fail(); }; - if (p.len < 10) { fail(); }; // at minimum "/tmp/temp.<1 hex>" + assert(!(fd < 0)); + assert(!(p.len < 10)); // at minimum "/tmp/temp.<1 hex>" // Path bytes must start with "/tmp/temp." and live in temp's // static buffer (NUL-terminated for syscall handoff). - if (p[0] != 47u8) { fail(); }; // '/' - if (!streq(strslice(p, 0, 10), "/tmp/temp.")) { fail(); }; - if (p.ptr[p.len] != 0u8) { fail(); }; + assert(!(p[0] != 47u8)); // '/' + assert(!(!streq(strslice(p, 0, 10), "/tmp/temp."))); + assert(!(p.ptr[p.len] != 0u8)); // Build fill payload, write it, lseek to 0, read it back. let wbuf: [64]u8; @@ -75,11 +62,11 @@ fn streq(a: str, b: str) bool = { for (k < sz[i]) { wbuf[k] = fill[i]; k += 1; }; if (sz[i] > 0) { let wr: i64 = os.write(fd, &wbuf[0], sz[i]: u64); - if (wr != sz[i]: i64) { fail(); }; + assert(!(wr != sz[i]: i64)); }; let r: i64 = os.lseek(fd, 0i64, os.whence.SET); - if (r != 0i64) { fail(); }; + assert(!(r != 0i64)); let rbuf: [64]u8; let z: i32 = 0; @@ -87,22 +74,22 @@ fn streq(a: str, b: str) bool = { let rd: i64 = 0i64; if (sz[i] > 0) { rd = os.read(fd, &rbuf[0], sz[i]: u64); - if (rd != sz[i]: i64) { fail(); }; + assert(!(rd != sz[i]: i64)); }; let k2: i32 = 0; for (k2 < sz[i]) { - if (rbuf[k2] != fill[i]) { fail(); }; + assert(!(rbuf[k2] != fill[i])); k2 += 1; }; // File exists pre-cleanup. - if (os.access(p, 0i32) != 0) { fail(); }; + assert(!(os.access(p, 0i32) != 0)); - if (os.close(fd) != 0) { fail(); }; - if (os.remove(p) != 0) { fail(); }; + assert(!(os.close(fd) != 0)); + assert(!(os.remove(p) != 0)); // Cleanup landed. - if (os.access(p, 0i32) == 0) { fail(); }; + assert(!(os.access(p, 0i32) == 0)); i += 1; }; @@ -127,7 +114,7 @@ fn strslice(p: str, lo: i32, hi: i32) str = { let p1: str; match (temp.named(&fd1, &p1, "/tmp", temp.mode.WRITE, 384i32)) { case void => {}; - case let e: os.oserror => fail(); + case let e: os.oserror => abort(); }; // Snapshot p1's bytes BEFORE the second call clobbers the buffer, @@ -146,22 +133,22 @@ fn strslice(p: str, lo: i32, hi: i32) str = { let p2: str; match (temp.named(&fd2, &p2, "/tmp", temp.mode.WRITE, 384i32)) { case void => {}; - case let e: os.oserror => fail(); + case let e: os.oserror => abort(); }; // Same buffer (Hare docs: "overwritten on subsequent calls"), // distinct path bytes (random suffix differs). - if (p1.ptr != p2.ptr) { fail(); }; - if (streq(strslice(p2, 0, p2.len), psnap)) { fail(); }; + assert(!(p1.ptr != p2.ptr)); + assert(!(streq(strslice(p2, 0, p2.len), psnap))); // Both fds are distinct. - if (fd1 == fd2) { fail(); }; + assert(!(fd1 == fd2)); - if (os.close(fd2) != 0) { fail(); }; - if (os.remove(p2) != 0) { fail(); }; + assert(!(os.close(fd2) != 0)); + assert(!(os.remove(p2) != 0)); - if (os.close(fd1) != 0) { fail(); }; - if (os.remove(psnap) != 0) { fail(); }; + assert(!(os.close(fd1) != 0)); + assert(!(os.remove(psnap) != 0)); }; // NOTE: temp.file() has no test of its own. The function is a thin @@ -184,12 +171,12 @@ fn strslice(p: str, lo: i32, hi: i32) str = { let i: i32 = 0; for (i < 2) { let d: str = temp.dir(); - if (d.len < 6) { fail(); }; - if (!streq(strslice(d, 0, 5), "/tmp/")) { fail(); }; - if (d.ptr[d.len] != 0u8) { fail(); }; + assert(!(d.len < 6)); + assert(!(!streq(strslice(d, 0, 5), "/tmp/"))); + assert(!(d.ptr[d.len] != 0u8)); // Dir exists. - if (os.access(d, 0i32) != 0) { fail(); }; + assert(!(os.access(d, 0i32) != 0)); // Snapshot the dir path into a local NUL-terminated buffer: // the os.* path entrypoints now copy through lib/os.pathbuf @@ -217,21 +204,21 @@ fn strslice(p: str, lo: i32, hi: i32) str = { cview.ptr = &cbuf[0]; cview.len = off; let cflags: os.flag = os.flag.WRONLY | os.flag.CREATE | os.flag.EXCL; let fd: i32 = os.open(cview, cflags, 384i32); - if (fd < 0) { fail(); }; + assert(!(fd < 0)); let payload: [3]u8; payload[0] = 88u8; payload[1] = 89u8; payload[2] = 90u8; // "XYZ" let wr: i64 = os.write(fd, &payload[0], 3u64); - if (wr != 3i64) { fail(); }; - if (os.close(fd) != 0) { fail(); }; - if (os.remove(cview) != 0) { fail(); }; + assert(!(wr != 3i64)); + assert(!(os.close(fd) != 0)); + assert(!(os.remove(cview) != 0)); }; // Rmdir uses dview (more robust if the static buffer were // touched between dir() and here). - if (os.rmdir(dview) != 0) { fail(); }; + assert(!(os.rmdir(dview) != 0)); // Cleanup landed. - if (os.access(dview, 0i32) == 0) { fail(); }; + assert(!(os.access(dview, 0i32) == 0)); i += 1; }; @@ -252,18 +239,18 @@ fn strslice(p: str, lo: i32, hi: i32) str = { dsnap.len = snaplen; let d2: str = temp.dir(); - if (d1.ptr != d2.ptr) { fail(); }; // same static buffer - if (streq(strslice(d2, 0, d2.len), dsnap)) { fail(); }; + assert(!(d1.ptr != d2.ptr)); // same static buffer + assert(!(streq(strslice(d2, 0, d2.len), dsnap))); // Cleanup both, using snap for d1's old contents. - if (os.rmdir(d2) != 0) { fail(); }; - if (os.rmdir(dsnap) != 0) { fail(); }; + assert(!(os.rmdir(d2) != 0)); + assert(!(os.rmdir(dsnap) != 0)); }; export fn main() i32 = { - signalled = 1; namedroundtrip(); - signalled = 2; namedoverwrite(); - signalled = 3; dirlifecycle(); - signalled = 4; diruniqueness(); + namedroundtrip(); + namedoverwrite(); + dirlifecycle(); + diruniqueness(); return 0; }; diff --git a/lib/time/timetest.ww b/lib/time/timetest.ww index 638f6baa..d5ac9fef 100644 --- a/lib/time/timetest.ww +++ b/lib/time/timetest.ww @@ -1,16 +1,12 @@ // timetest — exercises lib/time. Run with `out/bin/ww run -// lib/time/timetest.ww`. Same `signalled`-then-fail()-with-+10 -// pattern as fmttest / logtest / stattest so a non-zero exit -// pinpoints the offending scenario. +// lib/time/timetest.ww`. A failing row aborts via the assert/abort +// builtin (task #5 @test conversion). package time_test; -import os; import time; -let signalled: i32 = 0; -fn fail() void = { os.exit(signalled + 10); }; // ---- constants: load-bearing names + values ---------------------------- // @@ -19,16 +15,16 @@ fn fail() void = { os.exit(signalled + 10); }; // ref/hare/time/duration.ha:9-18. @test fn constants() void = { - if ((time.nanosecond: i64) != 1i64) { fail(); }; - if ((time.microsecond: i64) != 1000i64) { fail(); }; - if ((time.millisecond: i64) != 1000000i64) { fail(); }; - if ((time.second: i64) != 1000000000i64) { fail(); }; + assert(!((time.nanosecond: i64) != 1i64)); + assert(!((time.microsecond: i64) != 1000i64)); + assert(!((time.millisecond: i64) != 1000000i64)); + assert(!((time.second: i64) != 1000000000i64)); // "Roundtrip" check: derived multiples land on the canonical // nanosecond count. Catches a future re-derivation drift. - if (5i64 * (time.second: i64) != 5000000000i64) { fail(); }; - if (3i64 * (time.millisecond: i64) != 3000000i64) { fail(); }; - if (7i64 * (time.microsecond: i64) != 7000i64) { fail(); }; + assert(!(5i64 * (time.second: i64) != 5000000000i64)); + assert(!(3i64 * (time.millisecond: i64) != 3000000i64)); + assert(!(7i64 * (time.microsecond: i64) != 7000i64)); }; // ---- now(monotonic) is monotonic across two calls ---------------------- @@ -38,7 +34,7 @@ fn fail() void = { os.exit(signalled + 10); }; let b = time.now(time.clock.monotonic); // Two back-to-back calls — b can equal a (same ns tick) but // must never precede it. - if (time.compare(a, b) > 0i8) { fail(); }; + assert(!(time.compare(a, b) > 0i8)); }; // ---- now(realtime) returns a post-2020 epoch --------------------------- @@ -51,9 +47,9 @@ fn fail() void = { os.exit(signalled + 10); }; @test fn nowrealtime() void = { let t = time.now(time.clock.realtime); - if (t.sec < 1577836800i64) { fail(); }; - if (t.nsec < 0i64) { fail(); }; - if (t.nsec >= 1000000000i64) { fail(); }; + assert(!(t.sec < 1577836800i64)); + assert(!(t.nsec < 0i64)); + assert(!(t.nsec >= 1000000000i64)); }; // ---- add: zero duration is identity ------------------------------------ @@ -62,8 +58,8 @@ fn fail() void = { os.exit(signalled + 10); }; let a: time.instant; a.sec = 100i64; a.nsec = 500i64; let r = time.add(a, 0i64); - if (r.sec != 100i64) { fail(); }; - if (r.nsec != 500i64) { fail(); }; + assert(!(r.sec != 100i64)); + assert(!(r.nsec != 500i64)); }; // ---- add: positive duration, no carry ---------------------------------- @@ -72,8 +68,8 @@ fn fail() void = { os.exit(signalled + 10); }; let a: time.instant; a.sec = 10i64; a.nsec = 100i64; let r = time.add(a, 200i64); - if (r.sec != 10i64) { fail(); }; - if (r.nsec != 300i64) { fail(); }; + assert(!(r.sec != 10i64)); + assert(!(r.nsec != 300i64)); }; // ---- add: positive duration, carries into next second ------------------ @@ -82,8 +78,8 @@ fn fail() void = { os.exit(signalled + 10); }; let a: time.instant; a.sec = 10i64; a.nsec = 999999900i64; let r = time.add(a, 200i64); - if (r.sec != 11i64) { fail(); }; - if (r.nsec != 100i64) { fail(); }; + assert(!(r.sec != 11i64)); + assert(!(r.nsec != 100i64)); }; // ---- add: full-second duration ----------------------------------------- @@ -92,8 +88,8 @@ fn fail() void = { os.exit(signalled + 10); }; let a: time.instant; a.sec = 5i64; a.nsec = 0i64; let r = time.add(a, (time.second: i64) * 3i64); - if (r.sec != 8i64) { fail(); }; - if (r.nsec != 0i64) { fail(); }; + assert(!(r.sec != 8i64)); + assert(!(r.nsec != 0i64)); }; // ---- add: negative duration, no borrow --------------------------------- @@ -102,8 +98,8 @@ fn fail() void = { os.exit(signalled + 10); }; let a: time.instant; a.sec = 10i64; a.nsec = 500i64; let r = time.add(a, -100i64); - if (r.sec != 10i64) { fail(); }; - if (r.nsec != 400i64) { fail(); }; + assert(!(r.sec != 10i64)); + assert(!(r.nsec != 400i64)); }; // ---- add: negative duration, borrows from previous second -------------- @@ -112,8 +108,8 @@ fn fail() void = { os.exit(signalled + 10); }; let a: time.instant; a.sec = 10i64; a.nsec = 100i64; let r = time.add(a, -200i64); - if (r.sec != 9i64) { fail(); }; - if (r.nsec != 999999900i64) { fail(); }; + assert(!(r.sec != 9i64)); + assert(!(r.nsec != 999999900i64)); }; // ---- diff: simple subtraction ------------------------------------------ @@ -123,7 +119,7 @@ fn fail() void = { os.exit(signalled + 10); }; let b: time.instant; b.sec = 12i64; b.nsec = 300i64; let d: i64 = time.diff(a, b): i64; // b - a = 2.0000002 sec = 2_000_000_200 ns - if (d != 2000000200i64) { fail(); }; + assert(!(d != 2000000200i64)); }; // ---- diff: reversed sign ----------------------------------------------- @@ -132,7 +128,7 @@ fn fail() void = { os.exit(signalled + 10); }; let a: time.instant; a.sec = 12i64; a.nsec = 300i64; let b: time.instant; b.sec = 10i64; b.nsec = 100i64; let d: i64 = time.diff(a, b): i64; - if (d != -2000000200i64) { fail(); }; + assert(!(d != -2000000200i64)); }; // ---- compare: -1 / 0 / +1 ladder --------------------------------------- @@ -140,43 +136,43 @@ fn fail() void = { os.exit(signalled + 10); }; @test fn comparelt() void = { let a: time.instant; a.sec = 1i64; a.nsec = 0i64; let b: time.instant; b.sec = 2i64; b.nsec = 0i64; - if (time.compare(a, b) != -1i8) { fail(); }; + assert(!(time.compare(a, b) != -1i8)); }; @test fn comparegt() void = { let a: time.instant; a.sec = 2i64; a.nsec = 0i64; let b: time.instant; b.sec = 1i64; b.nsec = 0i64; - if (time.compare(a, b) != 1i8) { fail(); }; + assert(!(time.compare(a, b) != 1i8)); }; @test fn compareeq() void = { let a: time.instant; a.sec = 5i64; a.nsec = 42i64; let b: time.instant; b.sec = 5i64; b.nsec = 42i64; - if (time.compare(a, b) != 0i8) { fail(); }; + assert(!(time.compare(a, b) != 0i8)); }; @test fn comparensec_only() void = { let a: time.instant; a.sec = 5i64; a.nsec = 100i64; let b: time.instant; b.sec = 5i64; b.nsec = 200i64; - if (time.compare(a, b) != -1i8) { fail(); }; - if (time.compare(b, a) != 1i8) { fail(); }; + assert(!(time.compare(a, b) != -1i8)); + assert(!(time.compare(b, a) != 1i8)); }; export fn main() i32 = { - signalled = 1; constants(); - signalled = 2; nowmonotonic(); - signalled = 3; nowrealtime(); - signalled = 4; addzero(); - signalled = 5; addpos_nocarry(); - signalled = 6; addpos_carry(); - signalled = 7; addpos_fullsecond(); - signalled = 8; addneg_noborrow(); - signalled = 9; addneg_borrow(); - signalled = 10; diffsimple(); - signalled = 11; diffneg(); - signalled = 12; comparelt(); - signalled = 13; comparegt(); - signalled = 14; compareeq(); - signalled = 15; comparensec_only(); + constants(); + nowmonotonic(); + nowrealtime(); + addzero(); + addpos_nocarry(); + addpos_carry(); + addpos_fullsecond(); + addneg_noborrow(); + addneg_borrow(); + diffsimple(); + diffneg(); + comparelt(); + comparegt(); + compareeq(); + comparensec_only(); return 0; }; diff --git a/lib/ww/asttest.ww b/lib/ww/asttest.ww index 8cb4652b..2276b5dc 100644 --- a/lib/ww/asttest.ww +++ b/lib/ww/asttest.ww @@ -3,108 +3,105 @@ // `ww run lib/ww/asttest.ww`. // // nkname is checked against every nkind value (the full ladder the -// switch replaced) plus the out-of-band fallback ("?"). A non-zero -// exit pinpoints the failing row (signalled + 10), same convention as -// toktest. `package main` + bare `import ast` mirrors wwdump (the -// external astprint consumer). +// switch replaced) plus the out-of-band fallback ("?"). A failing row +// aborts via the assert/abort builtin (task #5 @test conversion). +// `package main` + bare `import ast` mirrors wwdump (the external +// astprint consumer). package main; -import os; import ast; -let signalled: i32 = 0; -fn fail() void = { os.exit(signalled + 10); }; fn checkname(k: nkind, want: str) void = { - if (nkname(k) != want) { fail(); }; + assert(!(nkname(k) != want)); }; // One row per nkind value — same string the if-ladder returned. The // final row pins the unknown-kind fallback ("?"). @test fn nkname_cases() void = { - signalled = 100; checkname(nkind.N_NONE, "none"); - signalled = 101; checkname(nkind.N_INTLIT, "int"); - signalled = 102; checkname(nkind.N_FLOATLIT, "float"); - signalled = 103; checkname(nkind.N_STRLIT, "str"); - signalled = 104; checkname(nkind.N_RUNELIT, "rune"); - signalled = 105; checkname(nkind.N_TRUE, "true"); - signalled = 106; checkname(nkind.N_FALSE, "false"); - signalled = 107; checkname(nkind.N_NIL, "nil"); - signalled = 108; checkname(nkind.N_IDENT, "id"); + checkname(nkind.N_NONE, "none"); + checkname(nkind.N_INTLIT, "int"); + checkname(nkind.N_FLOATLIT, "float"); + checkname(nkind.N_STRLIT, "str"); + checkname(nkind.N_RUNELIT, "rune"); + checkname(nkind.N_TRUE, "true"); + checkname(nkind.N_FALSE, "false"); + checkname(nkind.N_NIL, "nil"); + checkname(nkind.N_IDENT, "id"); - signalled = 109; checkname(nkind.N_BIN, "bin"); - signalled = 110; checkname(nkind.N_UN, "un"); - signalled = 111; checkname(nkind.N_CALL, "call"); - signalled = 112; checkname(nkind.N_INDEX, "index"); - signalled = 113; checkname(nkind.N_DOT, "dot"); - signalled = 114; checkname(nkind.N_CAST, "cast"); - signalled = 115; checkname(nkind.N_STRUCTLIT, "structlit"); - signalled = 116; checkname(nkind.N_ARRLIT, "arrlit"); - signalled = 117; checkname(nkind.N_FIELD, "field"); - signalled = 118; checkname(nkind.N_ASSIGN, "assign"); - signalled = 119; checkname(nkind.N_ALLOC, "alloc"); - signalled = 120; checkname(nkind.N_FREE, "free"); - signalled = 121; checkname(nkind.N_RECV, "recv"); - signalled = 122; checkname(nkind.N_SLICE, "slice"); - signalled = 123; checkname(nkind.N_SPREAD, "spread"); + checkname(nkind.N_BIN, "bin"); + checkname(nkind.N_UN, "un"); + checkname(nkind.N_CALL, "call"); + checkname(nkind.N_INDEX, "index"); + checkname(nkind.N_DOT, "dot"); + checkname(nkind.N_CAST, "cast"); + checkname(nkind.N_STRUCTLIT, "structlit"); + checkname(nkind.N_ARRLIT, "arrlit"); + checkname(nkind.N_FIELD, "field"); + checkname(nkind.N_ASSIGN, "assign"); + checkname(nkind.N_ALLOC, "alloc"); + checkname(nkind.N_FREE, "free"); + checkname(nkind.N_RECV, "recv"); + checkname(nkind.N_SLICE, "slice"); + checkname(nkind.N_SPREAD, "spread"); - signalled = 124; checkname(nkind.N_BLOCK, "block"); - signalled = 125; checkname(nkind.N_EXPRSTMT, "exprstmt"); - signalled = 126; checkname(nkind.N_LET, "let"); - signalled = 127; checkname(nkind.N_RETURN, "return"); - signalled = 128; checkname(nkind.N_IF, "if"); - signalled = 129; checkname(nkind.N_FOR, "for"); - signalled = 130; checkname(nkind.N_FORRANGE, "forrange"); - signalled = 131; checkname(nkind.N_DEFER, "defer"); - signalled = 132; checkname(nkind.N_BREAK, "break"); - signalled = 133; checkname(nkind.N_CONTINUE, "continue"); - signalled = 134; checkname(nkind.N_SWITCH, "switch"); - signalled = 135; checkname(nkind.N_CASE, "case"); + checkname(nkind.N_BLOCK, "block"); + checkname(nkind.N_EXPRSTMT, "exprstmt"); + checkname(nkind.N_LET, "let"); + checkname(nkind.N_RETURN, "return"); + checkname(nkind.N_IF, "if"); + checkname(nkind.N_FOR, "for"); + checkname(nkind.N_FORRANGE, "forrange"); + checkname(nkind.N_DEFER, "defer"); + checkname(nkind.N_BREAK, "break"); + checkname(nkind.N_CONTINUE, "continue"); + checkname(nkind.N_SWITCH, "switch"); + checkname(nkind.N_CASE, "case"); - signalled = 136; checkname(nkind.N_FILE, "file"); - signalled = 137; checkname(nkind.N_USE, "use"); - signalled = 138; checkname(nkind.N_DEF, "def"); - signalled = 139; checkname(nkind.N_TYPEDECL, "typedecl"); - signalled = 140; checkname(nkind.N_FNDECL, "fn"); - signalled = 141; checkname(nkind.N_PARAM, "param"); + checkname(nkind.N_FILE, "file"); + checkname(nkind.N_USE, "use"); + checkname(nkind.N_DEF, "def"); + checkname(nkind.N_TYPEDECL, "typedecl"); + checkname(nkind.N_FNDECL, "fn"); + checkname(nkind.N_PARAM, "param"); - signalled = 142; checkname(nkind.N_TNAME, "tname"); - signalled = 143; checkname(nkind.N_TPTR, "tptr"); - signalled = 144; checkname(nkind.N_TSLICE, "tslice"); - signalled = 145; checkname(nkind.N_TARRAY, "tarray"); - signalled = 146; checkname(nkind.N_TFN, "tfn"); - signalled = 147; checkname(nkind.N_TSTRUCT, "tstruct"); - signalled = 148; checkname(nkind.N_TFIELD, "tfield"); - signalled = 149; checkname(nkind.N_TCHAN, "tchan"); + checkname(nkind.N_TNAME, "tname"); + checkname(nkind.N_TPTR, "tptr"); + checkname(nkind.N_TSLICE, "tslice"); + checkname(nkind.N_TARRAY, "tarray"); + checkname(nkind.N_TFN, "tfn"); + checkname(nkind.N_TSTRUCT, "tstruct"); + checkname(nkind.N_TFIELD, "tfield"); + checkname(nkind.N_TCHAN, "tchan"); - signalled = 150; checkname(nkind.N_ATTR, "attr"); - signalled = 151; checkname(nkind.N_TTUPLE, "ttuple"); - signalled = 152; checkname(nkind.N_TTAGGED, "ttagged"); - signalled = 153; checkname(nkind.N_TUPLE, "tuple"); - signalled = 154; checkname(nkind.N_MATCH, "match"); - signalled = 155; checkname(nkind.N_MCASE, "mcase"); - signalled = 156; checkname(nkind.N_TRYPROP, "tryprop"); - signalled = 157; checkname(nkind.N_TRYUNW, "tryunw"); - signalled = 158; checkname(nkind.N_MLET, "mlet"); - signalled = 159; checkname(nkind.N_MASSIGN, "massign"); + checkname(nkind.N_ATTR, "attr"); + checkname(nkind.N_TTUPLE, "ttuple"); + checkname(nkind.N_TTAGGED, "ttagged"); + checkname(nkind.N_TUPLE, "tuple"); + checkname(nkind.N_MATCH, "match"); + checkname(nkind.N_MCASE, "mcase"); + checkname(nkind.N_TRYPROP, "tryprop"); + checkname(nkind.N_TRYUNW, "tryunw"); + checkname(nkind.N_MLET, "mlet"); + checkname(nkind.N_MASSIGN, "massign"); - signalled = 160; checkname(nkind.N_TYPETEST, "typetest"); - signalled = 161; checkname(nkind.N_TYPEASSERT, "typeassert"); - signalled = 162; checkname(nkind.N_VOIDLIT, "voidlit"); - signalled = 163; checkname(nkind.N_TBANG, "tbang"); - signalled = 164; checkname(nkind.N_YIELD, "yield"); - signalled = 165; checkname(nkind.N_TENUM, "tenum"); - signalled = 166; checkname(nkind.N_TENUMMEMBER, "tenummember"); - signalled = 167; checkname(nkind.N_TPARAM, "tparam"); - signalled = 168; checkname(nkind.N_LAST, "last"); + checkname(nkind.N_TYPETEST, "typetest"); + checkname(nkind.N_TYPEASSERT, "typeassert"); + checkname(nkind.N_VOIDLIT, "voidlit"); + checkname(nkind.N_TBANG, "tbang"); + checkname(nkind.N_YIELD, "yield"); + checkname(nkind.N_TENUM, "tenum"); + checkname(nkind.N_TENUMMEMBER, "tenummember"); + checkname(nkind.N_TPARAM, "tparam"); + checkname(nkind.N_LAST, "last"); // Unknown kind → the post-switch fallback. N_LAST is the highest // named value (68); 69 is out of band, exercising the "?" tail. - signalled = 169; checkname(69: nkind, "?"); + checkname(69: nkind, "?"); }; export fn main() i32 = { - signalled = 1; nkname_cases(); + nkname_cases(); return 0; }; diff --git a/lib/ww/lex/toktest.ww b/lib/ww/lex/toktest.ww index 91414fe8..91fa004f 100644 --- a/lib/ww/lex/toktest.ww +++ b/lib/ww/lex/toktest.ww @@ -13,9 +13,11 @@ // \r, the c<0x20 and c==0x7f \xNN arms, and the printable tail) — // branches the 990_selfhost corpus does not exercise (source tokens // hold raw `\`+`n`, never a literal control byte). -// A non-zero exit pinpoints the failing row (signalled + 10), same -// convention as asciitest. `package main` + bare `import tok/lex` -// mirrors wwdump (the only other external lex consumer). +// A failing row aborts via the assert/abort builtin (task #5 @test +// conversion); per-row exit-code pinpoint is intentionally dropped (the +// abort reports the file, not the row; drew-t2-conversion-spec sec.5). +// `package main` + bare `import tok/lex` mirrors wwdump (the only other +// external lex consumer). package main; @@ -23,129 +25,126 @@ import os; import tok; import lex; -let signalled: i32 = 0; -fn fail() void = { os.exit(signalled + 10); }; fn checkname(k: tkind, want: str) void = { - if (tokname(k) != want) { fail(); }; + assert(!(tokname(k) != want)); }; // One row per tkind value — same string the if-ladder returned. The // final row pins the unknown-kind fallback (""). @test fn tokname_cases() void = { - signalled = 100; checkname(tkind.TK_NONE, ""); - signalled = 101; checkname(tkind.TK_EOF, "EOF"); - signalled = 102; checkname(tkind.TK_ERR, "ERR"); - signalled = 103; checkname(tkind.TK_IDENT, "IDENT"); - signalled = 104; checkname(tkind.TK_INT, "INT"); - signalled = 105; checkname(tkind.TK_FLOAT, "FLOAT"); - signalled = 106; checkname(tkind.TK_RUNE, "RUNE"); - signalled = 107; checkname(tkind.TK_STR, "STR"); + checkname(tkind.TK_NONE, ""); + checkname(tkind.TK_EOF, "EOF"); + checkname(tkind.TK_ERR, "ERR"); + checkname(tkind.TK_IDENT, "IDENT"); + checkname(tkind.TK_INT, "INT"); + checkname(tkind.TK_FLOAT, "FLOAT"); + checkname(tkind.TK_RUNE, "RUNE"); + checkname(tkind.TK_STR, "STR"); - signalled = 108; checkname(tkind.TK_FN, "fn"); - signalled = 109; checkname(tkind.TK_LET, "let"); - signalled = 110; checkname(tkind.TK_DEF, "def"); - signalled = 111; checkname(tkind.TK_IF, "if"); - signalled = 112; checkname(tkind.TK_ELSE, "else"); - signalled = 113; checkname(tkind.TK_FOR, "for"); - signalled = 114; checkname(tkind.TK_SWITCH, "switch"); - signalled = 115; checkname(tkind.TK_CASE, "case"); - signalled = 116; checkname(tkind.TK_RETURN, "return"); - signalled = 117; checkname(tkind.TK_USE, "import"); - signalled = 118; checkname(tkind.TK_TYPE, "type"); - signalled = 119; checkname(tkind.TK_STRUCT, "struct"); - signalled = 120; checkname(tkind.TK_DEFER, "defer"); - signalled = 121; checkname(tkind.TK_BREAK, "break"); - signalled = 122; checkname(tkind.TK_CONTINUE, "continue"); - signalled = 123; checkname(tkind.TK_EXPORT, "export"); - signalled = 124; checkname(tkind.TK_PROC, "proc"); - signalled = 125; checkname(tkind.TK_CHAN, "chan"); - signalled = 126; checkname(tkind.TK_NIL, "nil"); - signalled = 127; checkname(tkind.TK_TRUE, "true"); - signalled = 128; checkname(tkind.TK_FALSE, "false"); - signalled = 129; checkname(tkind.TK_AS, "as"); - signalled = 130; checkname(tkind.TK_IS, "is"); - signalled = 131; checkname(tkind.TK_VOID, "void"); - signalled = 132; checkname(tkind.TK_YIELD, "yield"); - signalled = 133; checkname(tkind.TK_STATIC, "static"); - signalled = 134; checkname(tkind.TK_MATCH, "match"); - signalled = 135; checkname(tkind.TK_CONST, "const"); - signalled = 136; checkname(tkind.TK_UNDER, "_"); - signalled = 137; checkname(tkind.TK_ENUM, "enum"); - signalled = 138; checkname(tkind.TK_MODULE, "package"); + checkname(tkind.TK_FN, "fn"); + checkname(tkind.TK_LET, "let"); + checkname(tkind.TK_DEF, "def"); + checkname(tkind.TK_IF, "if"); + checkname(tkind.TK_ELSE, "else"); + checkname(tkind.TK_FOR, "for"); + checkname(tkind.TK_SWITCH, "switch"); + checkname(tkind.TK_CASE, "case"); + checkname(tkind.TK_RETURN, "return"); + checkname(tkind.TK_USE, "import"); + checkname(tkind.TK_TYPE, "type"); + checkname(tkind.TK_STRUCT, "struct"); + checkname(tkind.TK_DEFER, "defer"); + checkname(tkind.TK_BREAK, "break"); + checkname(tkind.TK_CONTINUE, "continue"); + checkname(tkind.TK_EXPORT, "export"); + checkname(tkind.TK_PROC, "proc"); + checkname(tkind.TK_CHAN, "chan"); + checkname(tkind.TK_NIL, "nil"); + checkname(tkind.TK_TRUE, "true"); + checkname(tkind.TK_FALSE, "false"); + checkname(tkind.TK_AS, "as"); + checkname(tkind.TK_IS, "is"); + checkname(tkind.TK_VOID, "void"); + checkname(tkind.TK_YIELD, "yield"); + checkname(tkind.TK_STATIC, "static"); + checkname(tkind.TK_MATCH, "match"); + checkname(tkind.TK_CONST, "const"); + checkname(tkind.TK_UNDER, "_"); + checkname(tkind.TK_ENUM, "enum"); + checkname(tkind.TK_MODULE, "package"); - signalled = 139; checkname(tkind.TK_LPAREN, "("); - signalled = 140; checkname(tkind.TK_RPAREN, ")"); - signalled = 141; checkname(tkind.TK_LBRACE, "{"); - signalled = 142; checkname(tkind.TK_RBRACE, "}"); - signalled = 143; checkname(tkind.TK_LBRACK, "["); - signalled = 144; checkname(tkind.TK_RBRACK, "]"); - signalled = 145; checkname(tkind.TK_COMMA, ","); - signalled = 146; checkname(tkind.TK_SEMI, ";"); - signalled = 147; checkname(tkind.TK_COLON, ":"); - signalled = 148; checkname(tkind.TK_DOT, "."); - signalled = 149; checkname(tkind.TK_ELLIPSIS, "..."); - signalled = 150; checkname(tkind.TK_DOTDOT, ".."); - signalled = 151; checkname(tkind.TK_AT, "@"); - signalled = 152; checkname(tkind.TK_QUESTION, "?"); + checkname(tkind.TK_LPAREN, "("); + checkname(tkind.TK_RPAREN, ")"); + checkname(tkind.TK_LBRACE, "{"); + checkname(tkind.TK_RBRACE, "}"); + checkname(tkind.TK_LBRACK, "["); + checkname(tkind.TK_RBRACK, "]"); + checkname(tkind.TK_COMMA, ","); + checkname(tkind.TK_SEMI, ";"); + checkname(tkind.TK_COLON, ":"); + checkname(tkind.TK_DOT, "."); + checkname(tkind.TK_ELLIPSIS, "..."); + checkname(tkind.TK_DOTDOT, ".."); + checkname(tkind.TK_AT, "@"); + checkname(tkind.TK_QUESTION, "?"); - signalled = 153; checkname(tkind.TK_ASSIGN, "="); - signalled = 154; checkname(tkind.TK_PLUSEQ, "+="); - signalled = 155; checkname(tkind.TK_MINUSEQ, "-="); - signalled = 156; checkname(tkind.TK_STAREQ, "*="); - signalled = 157; checkname(tkind.TK_SLASHEQ, "/="); - signalled = 158; checkname(tkind.TK_PERCENTEQ, "%="); - signalled = 159; checkname(tkind.TK_AMPEQ, "&="); - signalled = 160; checkname(tkind.TK_PIPEEQ, "|="); - signalled = 161; checkname(tkind.TK_CARETEQ, "^="); - signalled = 162; checkname(tkind.TK_LSHIFTEQ, "<<="); - signalled = 163; checkname(tkind.TK_RSHIFTEQ, ">>="); + checkname(tkind.TK_ASSIGN, "="); + checkname(tkind.TK_PLUSEQ, "+="); + checkname(tkind.TK_MINUSEQ, "-="); + checkname(tkind.TK_STAREQ, "*="); + checkname(tkind.TK_SLASHEQ, "/="); + checkname(tkind.TK_PERCENTEQ, "%="); + checkname(tkind.TK_AMPEQ, "&="); + checkname(tkind.TK_PIPEEQ, "|="); + checkname(tkind.TK_CARETEQ, "^="); + checkname(tkind.TK_LSHIFTEQ, "<<="); + checkname(tkind.TK_RSHIFTEQ, ">>="); - signalled = 164; checkname(tkind.TK_PLUS, "+"); - signalled = 165; checkname(tkind.TK_MINUS, "-"); - signalled = 166; checkname(tkind.TK_STAR, "*"); - signalled = 167; checkname(tkind.TK_SLASH, "/"); - signalled = 168; checkname(tkind.TK_PERCENT, "%"); - signalled = 169; checkname(tkind.TK_AMP, "&"); - signalled = 170; checkname(tkind.TK_PIPE, "|"); - signalled = 171; checkname(tkind.TK_CARET, "^"); - signalled = 172; checkname(tkind.TK_TILDE, "~"); - signalled = 173; checkname(tkind.TK_LSHIFT, "<<"); - signalled = 174; checkname(tkind.TK_RSHIFT, ">>"); + checkname(tkind.TK_PLUS, "+"); + checkname(tkind.TK_MINUS, "-"); + checkname(tkind.TK_STAR, "*"); + checkname(tkind.TK_SLASH, "/"); + checkname(tkind.TK_PERCENT, "%"); + checkname(tkind.TK_AMP, "&"); + checkname(tkind.TK_PIPE, "|"); + checkname(tkind.TK_CARET, "^"); + checkname(tkind.TK_TILDE, "~"); + checkname(tkind.TK_LSHIFT, "<<"); + checkname(tkind.TK_RSHIFT, ">>"); - signalled = 175; checkname(tkind.TK_EQ, "=="); - signalled = 176; checkname(tkind.TK_NEQ, "!="); - signalled = 177; checkname(tkind.TK_LT, "<"); - signalled = 178; checkname(tkind.TK_LE, "<="); - signalled = 179; checkname(tkind.TK_GT, ">"); - signalled = 180; checkname(tkind.TK_GE, ">="); + checkname(tkind.TK_EQ, "=="); + checkname(tkind.TK_NEQ, "!="); + checkname(tkind.TK_LT, "<"); + checkname(tkind.TK_LE, "<="); + checkname(tkind.TK_GT, ">"); + checkname(tkind.TK_GE, ">="); - signalled = 181; checkname(tkind.TK_AND, "&&"); - signalled = 182; checkname(tkind.TK_OR, "||"); - signalled = 183; checkname(tkind.TK_NOT, "!"); + checkname(tkind.TK_AND, "&&"); + checkname(tkind.TK_OR, "||"); + checkname(tkind.TK_NOT, "!"); - signalled = 184; checkname(tkind.TK_LARROW, "<-"); - signalled = 185; checkname(tkind.TK_ARROW, "->"); - signalled = 186; checkname(tkind.TK_FATARROW, "=>"); + checkname(tkind.TK_LARROW, "<-"); + checkname(tkind.TK_ARROW, "->"); + checkname(tkind.TK_FATARROW, "=>"); - signalled = 187; checkname(tkind.TK_MODRESET, "//ww:module-reset"); - signalled = 188; checkname(tkind.TK_LAST, ""); + checkname(tkind.TK_MODRESET, "//ww:module-reset"); + checkname(tkind.TK_LAST, ""); // Unknown kind → the post-switch fallback. TK_LAST is the highest // named value (88); 89 is out of band, exercising the "" tail. - signalled = 189; checkname(89: tkind, ""); + checkname(89: tkind, ""); }; fn checkkw(s: str, want: tkind) void = { - if (kwlookup(s.ptr, s.len) != want) { fail(); }; + assert(!(kwlookup(s.ptr, s.len) != want)); }; // Table-driven (parallel-array idiom; tuple rows blocked by #111). The // kw rows pin all 30 keywords kwlookup recognises, 1:1 with the // kwnames/kwkinds table (and cmd/wcc/tok.c:18-47), incl. the two remaps // import->TK_USE and package->TK_MODULE. The nk rows pin the -// fall-through to TK_NONE. signalled = base + row keeps a failure -// pinpointable. Explicit dims, NOT [_]: [_] static-init silently +// fall-through to TK_NONE. Explicit dims, NOT [_]: [_] static-init silently // miscompiles to a zero-length array in-tree (probe, cc69daf), which // would void the loop body — the very hole a table test must not have. @test fn kwlookup_cases() void = { @@ -167,7 +166,6 @@ fn checkkw(s: str, want: tkind) void = { ]; let i: i32 = 0; for (i < len(kwin)) { - signalled = 200 + i; checkkw(kwin[i], kwexp[i]); i += 1; }; @@ -200,7 +198,6 @@ fn checkkw(s: str, want: tkind) void = { ]; let j: i32 = 0; for (j < len(nk)) { - signalled = 230 + j; checkkw(nk[j], tkind.TK_NONE); j += 1; }; @@ -211,17 +208,17 @@ fn checkkw(s: str, want: tkind) void = { // before each write so earlier (possibly longer) content past want.len // is irrelevant — only want.len bytes from offset 0 are compared. fn checkprint(fd: i32, t: *tok, want: str) void = { - if (os.lseek(fd, 0i64, os.whence.SET) != 0i64) { fail(); }; + assert(!(os.lseek(fd, 0i64, os.whence.SET) != 0i64)); tokprint(fd, t); - if (os.lseek(fd, 0i64, os.whence.SET) != 0i64) { fail(); }; + assert(!(os.lseek(fd, 0i64, os.whence.SET) != 0i64)); let rbuf: [256]u8; let z: i32 = 0; for (z < 256) { rbuf[z] = 0u8; z += 1; }; let rd: i64 = os.read(fd, &rbuf[0], want.len: u64); - if (rd != want.len: i64) { fail(); }; + assert(!(rd != want.len: i64)); let j: i32 = 0; for (j < want.len) { - if (rbuf[j] != want.ptr[j]) { fail(); }; + assert(!(rbuf[j] != want.ptr[j])); j += 1; }; }; @@ -232,45 +229,39 @@ fn checkprint(fd: i32, t: *tok, want: str) void = { @test fn tokprint_cases() void = { let flags: os.flag = os.flag.RDWR | os.flag.CREATE | os.flag.TRUNC; let fd: i32 = os.open("/tmp/ww_s9_tok.tmp", flags, 384i32); - if (fd < 0) { fail(); }; + assert(!(fd < 0)); let t: tok; t.file = "t"; t.line = 1; t.col = 1; - signalled = 300; t.kind = tkind.TK_STR; t.text = "\\\"\n\t\r\x01\x7fA"; checkprint(fd, &t, "t:1:1 STR \"\\\\\\\"\\n\\t\\r\\x01\\x7fA\"\n"); - signalled = 301; t.kind = tkind.TK_IDENT; t.text = "name"; checkprint(fd, &t, "t:1:1 IDENT \"name\"\n"); - signalled = 302; t.kind = tkind.TK_ERR; t.text = "oops"; checkprint(fd, &t, "t:1:1 ERR \"oops\"\n"); - signalled = 303; t.kind = tkind.TK_INT; t.uval = 42u64; checkprint(fd, &t, "t:1:1 INT 42\n"); - signalled = 304; t.kind = tkind.TK_RUNE; t.uval = 65u64; checkprint(fd, &t, "t:1:1 RUNE 65\n"); // Default arm: a kind outside the switch appends no value. - signalled = 305; t.kind = tkind.TK_NONE; checkprint(fd, &t, "t:1:1 \n"); - if (os.close(fd) != 0) { fail(); }; - if (os.remove("/tmp/ww_s9_tok.tmp") != 0) { fail(); }; + assert(!(os.close(fd) != 0)); + assert(!(os.remove("/tmp/ww_s9_tok.tmp") != 0)); }; fn checkfloat(src: str, want: u64) void = { @@ -278,8 +269,8 @@ fn checkfloat(src: str, want: u64) void = { lexinit(&l, "t", src.ptr, src.len: u64); let t: tok; lexnext(&l, &t); - if (t.kind != tkind.TK_FLOAT) { fail(); }; - if (t.uval != want) { fail(); }; + assert(!(t.kind != tkind.TK_FLOAT)); + assert(!(t.uval != want)); }; // #62 pin: lexnum's float fold routes through strconv.stof64 and must @@ -293,42 +284,34 @@ fn checkfloat(src: str, want: u64) void = { // boundary (tie rounds to even, tie+1 rounds up — also the only // >19-digit FRACTION rows), and an exact power of two. @test fn floatfold_cases() void = { - signalled = 400; checkfloat("1.0000000000000002", 0x3FF0000000000001u64); - signalled = 401; checkfloat("9007199254740993.0", 0x4340000000000000u64); - signalled = 402; checkfloat("1.2345e67", 0x4DDD4E421712C0B7u64); - signalled = 403; checkfloat("0.1", 0x3FB999999999999Au64); - signalled = 404; checkfloat("1.1", 0x3FF199999999999Au64); - signalled = 405; + checkfloat("1.0000000000000002", 0x3FF0000000000001u64); + checkfloat("9007199254740993.0", 0x4340000000000000u64); + checkfloat("1.2345e67", 0x4DDD4E421712C0B7u64); + checkfloat("0.1", 0x3FB999999999999Au64); + checkfloat("1.1", 0x3FF199999999999Au64); checkfloat("123456789012345678901234567890.0", 0x45F8EE90FF6C373Eu64); - signalled = 406; checkfloat("2.2250738585072014e-308", 0x0010000000000000u64); - signalled = 407; checkfloat("0.3", 0x3FD3333333333333u64); - signalled = 408; checkfloat("3.141592653589793", 0x400921FB54442D18u64); - signalled = 409; + checkfloat("0.3", 0x3FD3333333333333u64); + checkfloat("3.141592653589793", 0x400921FB54442D18u64); checkfloat("1.7976931348623157e308", 0x7FEFFFFFFFFFFFFFu64); - signalled = 410; checkfloat("1.7976931348623158e308", 0x7FEFFFFFFFFFFFFFu64); - signalled = 411; checkfloat("7.2057594037927933e16", 0x4370000000000000u64); - signalled = 412; + checkfloat("7.2057594037927933e16", 0x4370000000000000u64); checkfloat("1000000000000000000000.0", 0x444B1AE4D6E2EF50u64); - signalled = 413; checkfloat("1_000.5", 0x408F440000000000u64); - signalled = 414; + checkfloat("1_000.5", 0x408F440000000000u64); checkfloat("1.00000000000000011102230246251565404236316680908203125", 0x3FF0000000000000u64); - signalled = 415; checkfloat("1.00000000000000011102230246251565404236316680908203126", 0x3FF0000000000001u64); - signalled = 416; checkfloat("4503599627370497.5", 0x4330000000000002u64); - signalled = 417; checkfloat("0.5", 0x3FE0000000000000u64); - signalled = 418; checkfloat("1.0e308", 0x7FE1CCF385EBC8A0u64); - signalled = 419; + checkfloat("4503599627370497.5", 0x4330000000000002u64); + checkfloat("0.5", 0x3FE0000000000000u64); + checkfloat("1.0e308", 0x7FE1CCF385EBC8A0u64); checkfloat("2.225073858507202e-308", 0x0010000000000001u64); }; export fn main() i32 = { - signalled = 1; tokname_cases(); - signalled = 2; kwlookup_cases(); - signalled = 3; tokprint_cases(); - signalled = 4; floatfold_cases(); + tokname_cases(); + kwlookup_cases(); + tokprint_cases(); + floatfold_cases(); return 0; };