test: prove package initialization semantics
This commit is contained in:
@@ -75,31 +75,6 @@ fn astrow(label: str, src: str, needles: []str) void = {
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
fn rejectrow(label: str, src: str, needle: str) void = {
|
||||
let td: str = testenv.fresh();
|
||||
testenv.writefile(strings.concat(td, "/a.ww"), src);
|
||||
let tools: []str = ["wwdump", "wwdump_ww"];
|
||||
let stages: []str = ["cstage", "wwstage"];
|
||||
let errors: []str = ["", ""];
|
||||
let i: i32 = 0;
|
||||
for (i < tools.len) {
|
||||
let av: []str = [testenv.driver(tools[i]), "-a",
|
||||
strings.concat(td, "/a.ww")];
|
||||
let co: testenv.commandout;
|
||||
testenv.runcommand(td, td, stages[i], av, tmo(), &co);
|
||||
if (co.termination != exec.termination.EXIT || co.code == 0
|
||||
|| !testenv.has(co.stderr, needle)) {
|
||||
fail(label, strings.concat(stages[i], " accepted rejected import"));
|
||||
};
|
||||
errors[i] = strings.dup(co.stderr);
|
||||
i += 1;
|
||||
};
|
||||
if (!testenv.same(errors[0], errors[1])) {
|
||||
fail(label, "cs/ww parse diagnostics DIFFER");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
@test fn astproof() void = {
|
||||
let trailing: []str = ["(dot \"x\"", "(structlit",
|
||||
"(tname \"pkg.point\""];
|
||||
@@ -127,9 +102,11 @@ fn rejectrow(label: str, src: str, needle: str) void = {
|
||||
"package main;\n",
|
||||
"import stable acme.codec;\n",
|
||||
"fn main() i32 = { return 0; };\n"), aliased);
|
||||
rejectrow("blank-alias", strings.concat(
|
||||
// A blank N_USE deliberately has no `.str` qualifier, so astprint's
|
||||
// `(use` line has no quoted binding while remaining a real use node.
|
||||
let blank: []str = ["(use\n"];
|
||||
astrow("blank-import", strings.concat(
|
||||
"package main;\n",
|
||||
"import _ acme.codec;\n",
|
||||
"fn main() i32 = { return 0; };\n"),
|
||||
"blank import alias _ is not implemented");
|
||||
"fn main() i32 = { return 0; };\n"), blank);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user