lib/strings-core tests: hand-main plumbing -> assert (@test conversion B4)

bytes EXCLUDED: its green masked a real signalled corruption (filed;
conversion rides the fix). stringstest documents the per-row signalled
pinpoint loss.
This commit is contained in:
2026-06-10 18:52:53 +09:00
parent b6d9201ef5
commit 612e6d149c
4 changed files with 485 additions and 648 deletions

View File

@@ -8,33 +8,19 @@
// byte-wise and those would match byte-identically but obscure the
// ASCII semantics the test is asserting.
//
// Failure path: each @test fn bumps `signalled` to its slot index,
// `check` does `exit(signalled + 10)` on miscompare so the harness
// reports `WEXITSTATUS = 11..N` pointing at the failing scenario.
// Same convention as lib/log/logtest.
// Failure path: a miscompare aborts via the assert/abort builtin
// (task #5 @test conversion).
package fnmatch_test;
import fnmatch;
// Direct rt_syscall binding rather than `use os;` — os exports
// read/write/close, which collide with io.read/write/close under the
// driver's flat-scope concat. Mirrors logtest / fmttest / bufiotest.
@symbol("rt_syscall") fn syscall1ww(num: i64, a: i64) i64;
fn doexit(code: i32) void = {
syscall1ww(60i64, code: i64);
};
let signalled: i32 = 0;
fn fail() void = { doexit(signalled + 10); };
// check — pin one row. `flags` is taken as i32 and cast to
// fnmatch.flag so the test rows can read as integer bitmasks
// without dragging enum literals into every line.
fn check(pat: str, s: str, expected: bool, flags: i32) void = {
let f: fnmatch.flag = flags as fnmatch.flag;
if (fnmatch.fnmatch(pat, s, f) != expected) { fail(); };
assert(!(fnmatch.fnmatch(pat, s, f) != expected));
};
// ---- basic literal / wildcard cases ---------------------------------
@@ -263,13 +249,13 @@ fn check(pat: str, s: str, expected: bool, flags: i32) void = {
};
export fn main() i32 = {
signalled = 1; basic();
signalled = 2; brackets();
signalled = 3; ctype();
signalled = 4; period();
signalled = 5; noescape();
signalled = 6; musl_basic();
signalled = 7; pathname();
signalled = 8; combined();
basic();
brackets();
ctype();
period();
noescape();
musl_basic();
pathname();
combined();
return 0;
};