test: roster appends struct call rvalues; cursor idiom retired (#34)

This commit is contained in:
2026-08-08 14:12:16 +09:00
parent 50d70e74e4
commit df453100d0

View File

@@ -55,43 +55,32 @@ type ent = struct {
moddir: str, // probe-only: completeness key moddir: str, // probe-only: completeness key
}; };
// #34: append() rejects struct-call-result sources, so the roster is a // Row constructors; the roster appends their results directly (#34
// preallocated slice filled by per-row field writes behind a running // closed — append accepts struct call rvalues).
// cursor; the cursor total re-proves the NENTEXPECT count. fn fx(f: str) ent = {
fn zeroent(e: *ent) void = { let e: ent;
e.fixture = ""; e.probe = ""; e.inc = ""; e.mode = MID; e.fixture = f; e.probe = ""; e.inc = ""; e.mode = MID;
e.cite = ""; e.sentinel = ""; e.moddir = ""; e.cite = ""; e.sentinel = ""; e.moddir = "";
return e;
}; };
fn fx(es: []ent, k: *i32, f: str) void = { fn fxi(f: str, inc: str) ent = {
let i: i32 = *k; let e: ent = fx(f);
es[i].fixture = f; e.inc = inc;
*k = i + 1; return e;
}; };
fn fxi(es: []ent, k: *i32, f: str, inc: str) void = { fn pr(p: str, sentinel: str, moddir: str) ent = {
let i: i32 = *k; let e: ent = fx("");
es[i].fixture = f; e.probe = p;
es[i].inc = inc; e.sentinel = sentinel; e.moddir = moddir;
*k = i + 1; return e;
}; };
fn pr(es: []ent, k: *i32, p: str, sentinel: str, moddir: str) void = { fn pri(p: str, inc: str, sentinel: str, moddir: str) ent = {
let i: i32 = *k; let e: ent = pr(p, sentinel, moddir);
es[i].probe = p; e.inc = inc;
es[i].sentinel = sentinel; return e;
es[i].moddir = moddir;
*k = i + 1;
};
fn pri(es: []ent, k: *i32, p: str, inc: str, sentinel: str,
moddir: str) void = {
let i: i32 = *k;
es[i].probe = p;
es[i].inc = inc;
es[i].sentinel = sentinel;
es[i].moddir = moddir;
*k = i + 1;
}; };
// The 44-unit roster. Graduation history lives in git (the retired C // The 44-unit roster. Graduation history lives in git (the retired C
@@ -99,73 +88,68 @@ fn pri(es: []ent, k: *i32, p: str, inc: str, sentinel: str,
// would need them. // would need them.
fn corpus() []ent = { fn corpus() []ent = {
let es: []ent = alloc([], NENTEXPECT: u64)!; let es: []ent = alloc([], NENTEXPECT: u64)!;
es.len = NENTEXPECT; append(es, fx("lib/bytes/bytes_test.ww"));
let z: i32 = 0; append(es, fx("lib/dirs/dirs_test.ww"));
for (z < es.len) { zeroent(&es[z]); z += 1; }; append(es, fx("lib/encoding/base32/base32_test.ww"));
let n: i32 = 0; append(es, fx("lib/encoding/hex/hex_test.ww"));
let k: *i32 = &n; append(es, fx("lib/encoding/utf8/utf8_test.ww"));
fx(es, k, "lib/bytes/bytes_test.ww"); append(es, fx("lib/getopt/getopt_test.ww"));
fx(es, k, "lib/dirs/dirs_test.ww"); append(es, fx("lib/hash/adler32/adler32_test.ww"));
fx(es, k, "lib/encoding/base32/base32_test.ww"); append(es, fx("lib/hash/crc16/crc16_test.ww"));
fx(es, k, "lib/encoding/hex/hex_test.ww"); append(es, fx("lib/hash/crc32/crc32_test.ww"));
fx(es, k, "lib/encoding/utf8/utf8_test.ww"); append(es, fx("lib/hash/crc64/crc64_test.ww"));
fx(es, k, "lib/getopt/getopt_test.ww"); append(es, fx("lib/hash/siphash/siphash_test.ww"));
fx(es, k, "lib/hash/adler32/adler32_test.ww"); append(es, fx("lib/math/checked/checked_test.ww"));
fx(es, k, "lib/hash/crc16/crc16_test.ww"); append(es, fx("lib/math/random/random_test.ww"));
fx(es, k, "lib/hash/crc32/crc32_test.ww"); append(es, fx("lib/memio/memio_test.ww"));
fx(es, k, "lib/hash/crc64/crc64_test.ww"); append(es, fx("lib/os/os_test.ww"));
fx(es, k, "lib/hash/siphash/siphash_test.ww"); append(es, pr("package main;\nimport os.exec;\nfn main() i32 = { return 0; };\n",
fx(es, k, "lib/math/checked/checked_test.ww"); "package exec;", "lib/os/exec"));
fx(es, k, "lib/math/random/random_test.ww"); append(es, fx("lib/regex/regex_test.ww"));
fx(es, k, "lib/memio/memio_test.ww"); append(es, fx("lib/strconv/test/ftos_test.ww"));
fx(es, k, "lib/os/os_test.ww"); append(es, fx("lib/strconv/test/stof_test.ww"));
pr(es, k, "package main;\nimport os.exec;\nfn main() i32 = { return 0; };\n", append(es, fx("lib/strconv/test/int_test.ww"));
"package exec;", "lib/os/exec"); append(es, fx("lib/strings/strings_test.ww"));
fx(es, k, "lib/regex/regex_test.ww"); append(es, fx("lib/temp/temp_test.ww"));
fx(es, k, "lib/strconv/test/ftos_test.ww"); append(es, fx("lib/time/time_test.ww"));
fx(es, k, "lib/strconv/test/stof_test.ww"); append(es, fx("lib/bufio/bufio_test.ww"));
fx(es, k, "lib/strconv/test/int_test.ww"); append(es, fx("lib/fmt/fmt_test.ww"));
fx(es, k, "lib/strings/strings_test.ww"); append(es, pr("package main;\nimport sort;\nfn main() i32 = { return 0; };\n",
fx(es, k, "lib/temp/temp_test.ww"); "package sort;", "lib/sort"));
fx(es, k, "lib/time/time_test.ww"); append(es, pr("package main;\nimport path;\nfn main() i32 = { return 0; };\n",
fx(es, k, "lib/bufio/bufio_test.ww"); "package path;", "lib/path"));
fx(es, k, "lib/fmt/fmt_test.ww"); append(es, pr("package main;\nimport endian;\nfn main() i32 = { return 0; };\n",
pr(es, k, "package main;\nimport sort;\nfn main() i32 = { return 0; };\n", "package endian;", "lib/endian"));
"package sort;", "lib/sort"); append(es, pr("package main;\nimport net;\nfn main() i32 = { return 0; };\n",
pr(es, k, "package main;\nimport path;\nfn main() i32 = { return 0; };\n", "package net;", "lib/net"));
"package path;", "lib/path"); append(es, pr("package main;\nimport hash;\nfn main() i32 = { return 0; };\n",
pr(es, k, "package main;\nimport endian;\nfn main() i32 = { return 0; };\n", "package hash;", "lib/hash"));
"package endian;", "lib/endian");
pr(es, k, "package main;\nimport net;\nfn main() i32 = { return 0; };\n",
"package net;", "lib/net");
pr(es, k, "package main;\nimport hash;\nfn main() i32 = { return 0; };\n",
"package hash;", "lib/hash");
// fnv lives off the driver's default root (lib/hash/fnv) // fnv lives off the driver's default root (lib/hash/fnv)
pri(es, k, "package main;\nimport fnv;\nfn main() i32 = { return 0; };\n", append(es, pri("package main;\nimport fnv;\nfn main() i32 = { return 0; };\n",
"lib/hash/fnv", "package fnv;", "lib/hash/fnv"); "lib/hash/fnv", "package fnv;", "lib/hash/fnv"));
// sentinel is a fn, not `package math;` — lib/math is also package // sentinel is a fn, not `package math;` — lib/math is also package
// math, so a silent fallback there would still match // math, so a silent fallback there would still match
pr(es, k, "package main;\nimport crypto.math;\nfn main() i32 = { return 0; };\n", append(es, pr("package main;\nimport crypto.math;\nfn main() i32 = { return 0; };\n",
"fn rotl32", "lib/crypto/math"); "fn rotl32", "lib/crypto/math"));
pr(es, k, "package main;\nimport c.libc;\nfn main() i32 = { return 0; };\n", append(es, pr("package main;\nimport c.libc;\nfn main() i32 = { return 0; };\n",
"package libc;", "lib/c/libc"); "package libc;", "lib/c/libc"));
// root-only, ZERO-dep build -S: the one driver-leg edge every // root-only, ZERO-dep build -S: the one driver-leg edge every
// import probe misses (dep-count-0 unit composition). Folded in // import probe misses (dep-count-0 unit composition). Folded in
// from the retired 815/940/951 driver-parity carriers. No // from the retired 815/940/951 driver-parity carriers. No
// sentinel: there is no dep unit to prove. // sentinel: there is no dep unit to prove.
pr(es, k, "package main;\nfn main() i32 = { return 0; };\n", "", ""); append(es, pr("package main;\nfn main() i32 = { return 0; };\n", "", ""));
fx(es, k, "lib/ascii/ascii_test.ww"); append(es, fx("lib/ascii/ascii_test.ww"));
fx(es, k, "lib/encoding/base64/base64_test.ww"); append(es, fx("lib/encoding/base64/base64_test.ww"));
fx(es, k, "lib/errors/errno_test.ww"); append(es, fx("lib/errors/errno_test.ww"));
fx(es, k, "lib/log/log_test.ww"); append(es, fx("lib/log/log_test.ww"));
fx(es, k, "lib/os/stat_test.ww"); append(es, fx("lib/os/stat_test.ww"));
// toktest/asttest resolve `import syntax` via -I lib/ww, cf 905 // toktest/asttest resolve `import syntax` via -I lib/ww, cf 905
fxi(es, k, "lib/ww/syntax/tok_test.ww", "lib/ww"); append(es, fxi("lib/ww/syntax/tok_test.ww", "lib/ww"));
fxi(es, k, "lib/ww/syntax/ast_test.ww", "lib/ww"); append(es, fxi("lib/ww/syntax/ast_test.ww", "lib/ww"));
fx(es, k, "lib/crypto/sha256/sha256_test.ww"); append(es, fx("lib/crypto/sha256/sha256_test.ww"));
fx(es, k, "lib/fnmatch/fnmatch_test.ww"); append(es, fx("lib/fnmatch/fnmatch_test.ww"));
fx(es, k, "lib/shlex/shlex_test.ww"); append(es, fx("lib/shlex/shlex_test.ww"));
assert(n == NENTEXPECT); assert(es.len == NENTEXPECT);
return es; return es;
}; };