mirror of
https://github.com/morluto/rea.git
synced 2026-11-12 01:41:21 +00:00
* fix(javascript): require exact loader suffix case * fix(javascript): share exact loader mode across import resolution * test(process): align symlink fixture with filesystem checkpoints * test(javascript): normalize the module resolution oracle path separators * test(frida): assert the CLI spawn Evidence contract * test(mcp): use an unsupported analysis-view parent * test(browser): separate source-location line bounds from parity * fix(javascript): preserve uncertain loader provenance * test(javascript): cover uncertain require resolution * fix(javascript): retain conditional Electron evidence * fix(javascript): preserve timed semantic provenance * fix(javascript): retain conditional builtin effects * test(javascript): distinguish bundled host authority * fix(javascript): preserve nested loader invocation identity * test(javascript): qualify Electron fixture authority * fix(javascript): preserve loader invocation authority * fix(javascript): respect source order for resolver escapes * fix(javascript): check nested loader callable mutations * fix(javascript): retain conditional constructor requests * fix(reference): retain constructor loader relationships * fix(reference): follow nested loader callable paths * refactor(javascript): share callable mutation interpretation * fix(javascript): require exact package loader suffixes * refactor(javascript): unify conditional relation evidence * refactor(javascript): unify conditional node evidence * fix(javascript): retain unknown authority for mixed case sources * fix(javascript): preserve loader uncertainty for dotfiles * fix(reference): classify javascript suffix dotfiles * test(reference): cover suffix dotfiles through cli * fix(javascript): retain equivalent conditional built-in origins * fix(javascript): preserve wrapped resolver operation * fix(javascript): retain nested conditional built-in receivers * test(javascript): declare CommonJS in native addon fixtures * fix(javascript): retain wrapped resolver candidates * style: format merged native command schema * fix(javascript): preserve uncertain loader authority * test(javascript): require candidate preload evidence * test(javascript): cover reference loader member writes --------- Co-authored-by: ShuaixinHuang <1836656514@qq.com>
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
analyzeJavaScriptSemantics,
|
|
analyzeParsedJavaScriptSemantics,
|
|
} from "./javascriptSemanticAnalysis.js";
|
|
import { parseJavaScriptSource } from "./javascriptSourceParser.js";
|
|
import {
|
|
onlyBinding,
|
|
topLevelBinding,
|
|
} from "./javascriptSemanticAnalysis.fixture.js";
|
|
|
|
describe("JavaScript semantic binding provenance", () => {
|
|
it("keeps opaque expression results unknown instead of declaring them local", () => {
|
|
const ir = analyzeJavaScriptSemantics(`
|
|
const called = loadFeature();
|
|
const constructed = new Feature();
|
|
const tagged = tag\`feature\`;
|
|
const dynamicRequired = require(specifier);
|
|
const sequence = (0, loadFeature());
|
|
const assignment = (slot = loadFeature());
|
|
async function readLater(parameter = require("fallback")) {
|
|
const awaited = await loadFeature();
|
|
return awaited;
|
|
}
|
|
try { loadFeature(); } catch (caught) { void caught; }
|
|
function* yieldLater() {
|
|
const yielded = yield loadFeature();
|
|
return yielded;
|
|
}
|
|
`);
|
|
|
|
for (const name of [
|
|
"called",
|
|
"constructed",
|
|
"tagged",
|
|
"dynamicRequired",
|
|
"sequence",
|
|
"assignment",
|
|
"awaited",
|
|
"yielded",
|
|
"parameter",
|
|
"caught",
|
|
]) {
|
|
expect(onlyBinding(ir, name).provenance).toMatchObject({
|
|
status: "unknown",
|
|
origins: [],
|
|
});
|
|
}
|
|
});
|
|
|
|
it("recognizes explicit local values and preserves exact module aliases", () => {
|
|
const source = `
|
|
const object = { value: 1 };
|
|
const array = [1, 2];
|
|
const template = \`feature\`;
|
|
const primitive = -1 + 2;
|
|
const derived = loadFeature() + 1;
|
|
const derivedText = \`value: \${loadFeature()}\`;
|
|
let uninitialized;
|
|
const callable = () => 1;
|
|
const Constructed = class {};
|
|
const imported = require("feature");
|
|
const alias = imported;
|
|
const sequence = (0, require("sequence-feature"));
|
|
const assignment = (slot = require("assignment-feature"));
|
|
`;
|
|
const parsed = parseJavaScriptSource(source, "main.cjs");
|
|
if (parsed === null) throw new Error("fixture did not parse");
|
|
const ir = analyzeParsedJavaScriptSemantics(parsed);
|
|
const candidate = analyzeJavaScriptSemantics(source);
|
|
expect(topLevelBinding(candidate, "alias").provenance).toMatchObject({
|
|
status: "ambiguous",
|
|
origins: [{ specifier: "feature", loaderAuthority: "candidate" }],
|
|
});
|
|
|
|
for (const name of [
|
|
"object",
|
|
"array",
|
|
"template",
|
|
"primitive",
|
|
"derived",
|
|
"derivedText",
|
|
"uninitialized",
|
|
"callable",
|
|
"Constructed",
|
|
])
|
|
expect(topLevelBinding(ir, name).provenance).toMatchObject({
|
|
status: "local",
|
|
origins: [],
|
|
});
|
|
|
|
expect(topLevelBinding(ir, "alias").provenance).toMatchObject({
|
|
status: "module",
|
|
origins: [{ specifier: "feature" }],
|
|
});
|
|
expect(topLevelBinding(ir, "sequence").provenance).toMatchObject({
|
|
status: "module",
|
|
origins: [{ specifier: "sequence-feature" }],
|
|
});
|
|
expect(topLevelBinding(ir, "assignment").provenance).toMatchObject({
|
|
status: "module",
|
|
origins: [{ specifier: "assignment-feature" }],
|
|
});
|
|
});
|
|
});
|