perf(javascript): cache canonical export comparison sort keys (#1028)
This commit is contained in:
@@ -135,9 +135,13 @@ describe("source-produced export comparison inventories", () => {
|
||||
`export const candidate${String(index)} = ${String(index)};`,
|
||||
).join("\n");
|
||||
const inventorySource = `export default function parse(value) {\n${returnSites}\n throw new Error("no match");\n}\n${extraExports}`;
|
||||
const pairedVariantsSource = `export default function parse(value) {
|
||||
${returnSites}
|
||||
throw new Error("no match");
|
||||
}`;
|
||||
const [inventoryLeft, inventoryRight] = await Promise.all([
|
||||
analyzeSourceEvidence(inventorySource),
|
||||
analyzeSourceEvidence(inventorySource),
|
||||
analyzeSourceEvidence(pairedVariantsSource),
|
||||
]);
|
||||
const variants = compareEvidence(inventoryLeft, inventoryRight);
|
||||
expect(variants.left).toMatchObject({ status: "selected" });
|
||||
|
||||
@@ -88,6 +88,21 @@ describe("JavaScript export return-shape comparison", () => {
|
||||
expect(result.coverage.status).toBe("partial");
|
||||
});
|
||||
|
||||
it("orders multiple changed paths deterministically across Unicode names", async () => {
|
||||
const graphs = await analyzeSources({
|
||||
left: `export default () => ({ type: "item", zeta: 1, alpha: 1, "éclair": 1 });`,
|
||||
right: `export default () => ({ type: "item", zeta: 2, alpha: 2, "éclair": 2 });`,
|
||||
});
|
||||
const first = compare(...graphs);
|
||||
const second = compare(...graphs);
|
||||
|
||||
expect(new Set(first.changes.map(({ path }) => path))).toEqual(
|
||||
new Set(["/alpha", "/zeta", "/éclair"]),
|
||||
);
|
||||
expect(first.changes).toEqual(second.changes);
|
||||
expect(first.comparison_id).toBe(second.comparison_id);
|
||||
});
|
||||
|
||||
it("does not pair discriminants that an unknown trailing spread can overwrite", async () => {
|
||||
const [left, right] = await analyzeSources({
|
||||
left: `
|
||||
|
||||
Reference in New Issue
Block a user