test: prove declared package import semantics

This commit is contained in:
2026-08-14 03:08:16 +09:00
parent 6efe9b70d4
commit a841278333
11 changed files with 1001 additions and 131 deletions

View File

@@ -22,11 +22,12 @@ package direnum_test;
// source order); the two stages' units are byte-identical.
//
// rejects — the authoritative loader-reject table over private trees:
// root-conflict ("conflicting package names"), import-leaf ("does
// not match import path"), root-missing and root-invalid ("invalid
// or missing package clause"), attest-noncanon ("@test declaration
// outside *_test.ww" — Go's test-file contract); per row both stages
// fail, carry the needle, and their captured stderr is byte-identical.
// root-conflict ("conflicting package names"), root-missing and
// root-invalid ("invalid or missing package clause"), attest-noncanon
// ("@test declaration outside *_test.ww" — Go's test-file contract);
// per row both stages fail, carry the needle, and their captured stderr is
// byte-identical. The former import-leaf rejection is now an accepted
// path/name-decoupling case and uses the imported declaration as qualifier.
//
// Dropped C machinery, not assertions: the ww_ww-absent skip gate
// (the Make target declares both drivers) and the unlink/rmdir
@@ -179,7 +180,7 @@ fn rejectpair(label: str, td: str, target: str, needle: str) void = {
"package other;\nfn spare() i32 = { return 0; };\n");
testenv.writefile(strings.concat(importbad, "/entry.ww"),
strings.concat("package main;\nimport wanted;\n",
"fn main() i32 = { return wanted.value(); };\n"));
"fn main() i32 = { return other.value(); };\n"));
testenv.writefile(strings.concat(wanted, "/a.ww"),
"package other;\nexport fn value() i32 = { return 0; };\n");
testenv.writefile(strings.concat(missing, "/a.ww"),
@@ -192,12 +193,28 @@ fn rejectpair(label: str, td: str, target: str, needle: str) void = {
"package attbad;\n",
"@test fn hidden() void = { assert(false); };\n"));
let tags: []str = ["root-conflict", "import-leaf", "root-missing",
let drvs: []str = ["ww", "ww_ww"];
let s: i32 = 0;
for (s < drvs.len) {
let out: str = strings.concat(td, "/import-name-", drvs[s]);
let av: []str = [testenv.driver(drvs[s]), "build", "-o", out,
strings.concat(importbad, "/entry.ww")];
if (runcode(td, strings.concat("import-name-build-", drvs[s]), av)
!= 0) {
fail("import-name", strings.concat(drvs[s], " build failed"));
};
let rav: []str = [out];
if (runcode(td, strings.concat("import-name-run-", drvs[s]), rav)
!= 0) {
fail("import-name", strings.concat(drvs[s], " run failed"));
};
s += 1;
};
let tags: []str = ["root-conflict", "root-missing",
"root-invalid", "attest-noncanon"];
let targets: []str = [rootbad, strings.concat(importbad,
"/entry.ww"), missing, invalid, attbad];
let targets: []str = [rootbad, missing, invalid, attbad];
let needles: []str = ["conflicting package names",
"does not match import path",
"invalid or missing package clause",
"invalid or missing package clause",
"@test declaration outside *_test.ww"];

View File

@@ -203,7 +203,7 @@ fn userow(label: str, apick: str, onecall: str) void = {
let rav: []str = [strings.concat(td, "/main")];
if (runcode(td, strings.concat("run_", drvs[s]), rav) != 0) {
fail(label, strings.concat(drvs[s], " run-exit != 0 (a ",
"file-global first-match hint routes one math.pick() to ",
"cross-file first-match hint routes one math.pick() to ",
"the wrong package -- #40)"));
};
testenv.clean(td);