Skip to content

Commit 0fdc5be

Browse files
committed
test(1336): use two-file fixture to validate Phase 8.3f as the resolution mechanism (#1350)
The previous single-file fixture resolved f3→e4 via the same-file name-lookup fallback, not through Phase 8.3f typeMap seeding. The updated fixture defines e4 in helpers.js (imported) so the same-file fallback cannot trigger: the edge must be produced by Phase 8.3f cross-referencing objectRestParamBindings with paramBindings from the WASM worker output.
1 parent 037bfb5 commit 0fdc5be

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

tests/integration/issue-1336-object-rest-param-resolution.test.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
* 4. build-edges.ts cross-references (2) and (3) to seed typeMap['eerest'] = { type: 'obj' }.
1616
* 5. resolveByMethodOrGlobal: typeMap['eerest'] → obj; typeMap['obj.e4'] → e4 → resolved edge.
1717
*
18+
* The fixture uses TWO files so that `e4` is not in the same file as the call site. This
19+
* ensures the same-file name-lookup fallback cannot accidentally resolve `eerest.e4()` to
20+
* the locally-defined `e4` — the edge MUST come from Phase 8.3f typeMap seeding. Without
21+
* `paramBindings` serialized through the WASM worker boundary, this test would fail.
22+
*
1823
* Native engine parity is tracked in #1349.
1924
*/
2025

@@ -25,9 +30,17 @@ import Database from 'better-sqlite3';
2530
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
2631
import { buildGraph } from '../../src/domain/graph/builder.js';
2732

28-
const FIXTURE_CODE = `
29-
function e1() { console.log("31"); }
30-
function e4() { console.log("34"); }
33+
// helpers.js defines e4 — imported and placed in an object literal in main.js.
34+
const HELPERS_CODE = `
35+
export function e1() { console.log("31"); }
36+
export function e4() { console.log("34"); }
37+
`;
38+
39+
// main.js imports e4 from helpers.js, wraps it in obj, and calls f3(obj).
40+
// f3 uses object-destructuring rest; eerest.e4() must resolve to e4 in helpers.js
41+
// via Phase 8.3f typeMap seeding — it cannot be found by the same-file name lookup.
42+
const MAIN_CODE = `
43+
import { e1, e4 } from './helpers.js';
3144
3245
var obj = { e1, e4 };
3346
@@ -42,7 +55,8 @@ let tmpDir: string;
4255

4356
beforeAll(async () => {
4457
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-1336-'));
45-
fs.writeFileSync(path.join(tmpDir, 'rest.js'), FIXTURE_CODE);
58+
fs.writeFileSync(path.join(tmpDir, 'helpers.js'), HELPERS_CODE);
59+
fs.writeFileSync(path.join(tmpDir, 'main.js'), MAIN_CODE);
4660
// Force WASM engine — native engine parity tracked in #1349.
4761
await buildGraph(tmpDir, { engine: 'wasm', incremental: false, skipRegistry: true });
4862
});

0 commit comments

Comments
 (0)