Files
reverse-engineering-anything/src/domain/javascript/javascriptReturnedReferenceCoverage.test.ts
T
morluto f62a2baad8 refactor(javascript): own coverage facts and reuse block prefixes
Separate syntax, semantic uncertainty, examination limits and observed Electron applicability at the static producer, then preserve them through worker, graph and retained/inline summary views. Derive the established parse_status from the same facts and leave historical measurements unknown. Give semantic resource-limit classifications one schema owner.

Replace repeated block-prefix searches and copies with collector-scoped syntax indexes. Keep invocation environments separate, charge indexing/replay to the existing work budget and yield during prefix work. Remove the superseded synchronous collector entrypoint.

Validated producer, worker, CLI/MCP, historical and partial-coverage regressions, plus actual cancellation during indexing. Bounded authored 128/256-call controls preserved all prior facts while replacing repeated search/copy work with one index pass; this is not a throughput or agent-token benchmark.
2026-10-25 09:49:26 +08:00

37 lines
1.4 KiB
TypeScript

import { expect, it } from "vitest";
import { analyzeJavaScriptSemantics } from "./javascriptSemanticAnalysis.js";
import { analyzeJavaScriptStaticSource } from "./javascriptStaticAnalysis.js";
import { RETURNED_REFERENCE_WIDENING_LIMITATION } from "./javascriptSemanticCoverage.js";
it("preserves possible ambient effects and discloses projection widening in source coverage", () => {
const source = `
function expose() { return Map.prototype; }
let cursor = { target: expose };
function walk(flag) {
while (flag) cursor = cursor.next;
patch(cursor.target());
}
fetch('/preserved');
new Map().get('/candidate');
`;
const ir = analyzeJavaScriptSemantics(source);
expect(ir.coverage).toMatchObject({ status: "partial", omittedCount: 0 });
expect(ir.coverage.widenedReturnedReferences?.length).toBeGreaterThan(0);
expect(ir.limitations).toContain(RETURNED_REFERENCE_WIDENING_LIMITATION);
const facts = analyzeJavaScriptStaticSource(source);
expect(facts.limitations).toContain(RETURNED_REFERENCE_WIDENING_LIMITATION);
expect(facts.analysis_coverage?.semantics.uncertainty).toContain(
"returned-reference-widening",
);
expect(facts.endpoints).toEqual(
expect.arrayContaining([
expect.objectContaining({ value: "/preserved", mechanism: "call:fetch" }),
expect.objectContaining({
value: "/candidate",
interpretation: "candidate",
}),
]),
);
});