mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 09:21:16 +00:00
test: strengthen regression oracles and cleanup ownership (#8152)
* test: strengthen suite oracles and cleanup ownership * test: reuse setup across independent scenarios (#8153) * Potential fix for pull request finding 'CodeQL / Improper code sanitization' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
1ddee1089b
commit
675d4076de
98 files changed
+1373
-1034
No files matched your search
@@ -46,6 +46,18 @@ it("keeps identical source text in separate syntax trees distinct", () => {
|
||||
expect(semanticCallableResultExpressions(second)[0]?.node).toBe(second.body);
|
||||
});
|
||||
|
||||
it("retains recovered yield syntax in a non-generator return", () => {
|
||||
const parsed = parseJavaScriptSource("function f(){ return (yield 1); }");
|
||||
expect(parsed?.errors.length).toBeGreaterThan(0);
|
||||
const callable = parsed?.program.body[0];
|
||||
if (!t.isFunctionDeclaration(callable))
|
||||
throw new Error("Expected recovered callable fixture");
|
||||
const results = semanticCallableResultExpressions(callable);
|
||||
expect(results.map(({ kind }) => kind)).toEqual(["return", "yield"]);
|
||||
expect(t.isYieldExpression(results[0]?.node)).toBe(true);
|
||||
expect(t.isNumericLiteral(results[1]?.node, { value: 1 })).toBe(true);
|
||||
});
|
||||
|
||||
it("retains empty results and bare return/yield source sites", () => {
|
||||
const empty = t.functionExpression(null, [], t.blockStatement([]));
|
||||
const emptyResult = semanticCallableResultExpressions(empty);
|
||||
|
||||
@@ -30,6 +30,18 @@ const allowedCycles = [
|
||||
["javascriptStaticAnalysisFindings.ts", "javascriptStaticAnalysisState.ts"],
|
||||
];
|
||||
|
||||
const allowedCycleEdges = [
|
||||
"electronStaticAnalysisTypes.ts -> javascriptStaticAnalysisTypes.ts",
|
||||
"javascriptRouteFacts.ts -> javascriptSourceCoordinates.ts",
|
||||
"javascriptSourceCoordinates.ts -> javascriptStaticAnalysisTypes.ts",
|
||||
"javascriptStaticAnalysisTypes.ts -> electronStaticAnalysisTypes.ts",
|
||||
"javascriptStaticAnalysisTypes.ts -> javascriptRouteFacts.ts",
|
||||
"javascriptRuntimeReconciliationActive.ts -> javascriptRuntimeReconciliationCaptureParsing.ts",
|
||||
"javascriptRuntimeReconciliationCaptureParsing.ts -> javascriptRuntimeReconciliationActive.ts",
|
||||
"javascriptStaticAnalysisFindings.ts -> javascriptStaticAnalysisState.ts",
|
||||
"javascriptStaticAnalysisState.ts -> javascriptStaticAnalysisFindings.ts",
|
||||
].sort();
|
||||
|
||||
const productionFiles = (directory: string): string[] => {
|
||||
const files: string[] = [];
|
||||
for (const name of readdirSync(directory)) {
|
||||
@@ -109,11 +121,18 @@ const stronglyConnected = (
|
||||
|
||||
describe("javascript semantic import cycles", () => {
|
||||
it("keeps the semantic modules out of one import cycle", () => {
|
||||
const cycles = stronglyConnected(importGraph()).map((cycle) =>
|
||||
cycle.join("\n"),
|
||||
);
|
||||
const graph = importGraph();
|
||||
const cycles = stronglyConnected(graph).map((cycle) => cycle.join("\n"));
|
||||
expect(cycles).toEqual(
|
||||
allowedCycles.map((cycle) => [...cycle].sort().join("\n")),
|
||||
);
|
||||
const internalEdges = allowedCycles.flatMap((cycle) =>
|
||||
cycle.flatMap((source) =>
|
||||
[...(graph.get(source) ?? [])]
|
||||
.filter((target) => cycle.includes(target))
|
||||
.map((target) => `${source} -> ${target}`),
|
||||
),
|
||||
);
|
||||
expect(internalEdges.sort()).toEqual(allowedCycleEdges);
|
||||
});
|
||||
});
|
||||
@@ -631,6 +631,7 @@ it("propagates branch guards through object properties and function calls", () =
|
||||
inspect(direct.action);
|
||||
inspect(called.action);
|
||||
`);
|
||||
expect(inspected).toHaveLength(2);
|
||||
for (const value of inspected) {
|
||||
const functions = symbolicVariants(value).filter(
|
||||
(candidate) => candidate.kind === "function",
|
||||
|
||||
Reference in new issue
Block a user