test(javascript): verify distinct module origins through reconstruction

This commit is contained in:
morluto
2026-10-10 01:45:01 +08:00
parent 41a228c1b0
commit 96b2b245fd
2 changed files with 33 additions and 16 deletions
@@ -1,16 +0,0 @@
import { expect, it } from "vitest";
import { analyzeJavaScriptSemantics } from "./javascriptSemanticAnalysis.js";
import { topLevelBinding } from "./javascriptSemanticAnalysis.fixture.js";
it("retains distinct module origins when a property contains the old separator", () => {
const result = analyzeJavaScriptSemantics(
'import * as ns from "./fixture.js"; const selected = choice ? ns["a\\0b"] : ns.a.b;',
);
const provenance = topLevelBinding(result, "selected").provenance;
expect(provenance.status).toBe("ambiguous");
expect(provenance.origins.map(({ importedPath }) => importedPath)).toEqual(
expect.arrayContaining([["a\0b"], ["a", "b"]]),
);
expect(provenance.origins).toHaveLength(2);
});