w6c: preserve grouped and qualified types in wwi
This commit is contained in:
@@ -132,6 +132,7 @@ fn m2positive(pkg: str) void = {
|
||||
"export def NEG: i32 = -7;\n",
|
||||
"export let counter: i32;\n",
|
||||
"export let grid: [4]i32;\n",
|
||||
"export let grouped: [(1 + 2) * 3]u8;\n",
|
||||
"export fn apply(f: fn(x: i32) i32, n: i32) i32;\n",
|
||||
"export fn risky() !i32;\n",
|
||||
"export fn matrix() [LIMIT]u8;\n",
|
||||
@@ -152,6 +153,10 @@ fn m2positive(pkg: str) void = {
|
||||
fail("synth",
|
||||
"cs.wwi != ww.wwi (const-expr / decl-kind unparse diverges)");
|
||||
};
|
||||
if (!testenv.has(testenv.readfile(cs),
|
||||
"export let grouped: [((1 + 2) * 3)]u8;")) {
|
||||
fail("synth", ".wwi changed grouped array-dimension semantics");
|
||||
};
|
||||
// #47: the @symbol attribute must survive the round-trip verbatim.
|
||||
if (!testenv.has(testenv.readfile(cs),
|
||||
"@symbol(\"rt_ext\") export fn ext")) {
|
||||
@@ -164,6 +169,43 @@ fn m2positive(pkg: str) void = {
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
@test fn m2qualified() void = {
|
||||
let td: str = testenv.fresh();
|
||||
let src: str = strings.concat(
|
||||
"//ww:module a.dep\n",
|
||||
"package dep;\n",
|
||||
"export type Clash = struct { x: i32 };\n",
|
||||
"//ww:module-reset\n",
|
||||
"package root;\n",
|
||||
"import a.dep;\n",
|
||||
"type Clash = struct { y: i32 };\n",
|
||||
"export fn use(x: dep.Clash) i32;\n");
|
||||
let p: str = strings.concat(td, "/qualified.ww");
|
||||
testenv.writefile(p, src);
|
||||
let cs: str = strings.concat(td, "/cs.wwi");
|
||||
let ws: str = strings.concat(td, "/ww.wwi");
|
||||
let cav: []str = [testenv.driver("w6c"), "-I", cs, p];
|
||||
if (!runok(td, "w6c", cav)) {
|
||||
fail("qualified", "w6c confused dep.Clash with private Clash");
|
||||
};
|
||||
let wav: []str = [testenv.driver("w6c_ww"), "-I", ws, p];
|
||||
if (!runok(td, "w6c_ww", wav)) {
|
||||
fail("qualified", "w6c_ww confused dep.Clash with private Clash");
|
||||
};
|
||||
if (!testenv.same(testenv.readfile(cs), testenv.readfile(ws))) {
|
||||
fail("qualified", "cs.wwi != ww.wwi");
|
||||
};
|
||||
if (!testenv.has(testenv.readfile(cs),
|
||||
"export fn use(x: dep.Clash) i32;")) {
|
||||
fail("qualified", ".wwi dropped the qualified signature");
|
||||
};
|
||||
let dav: []str = [testenv.driver("wwdump"), "-a", cs];
|
||||
if (!runok(td, "wwdump", dav)) {
|
||||
fail("qualified", "emitted .wwi does not re-parse");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
// #48 gate: the lib/types limit constants are `export def`s. Produce
|
||||
// types.wwi on both stages directly from the real lib source, assert
|
||||
// byte-id + re-parse + that the exported limits actually appear (a
|
||||
|
||||
Reference in New Issue
Block a user