mirror of
https://github.com/morluto/rea.git
synced 2026-11-08 15:56:35 +00:00
refactor(javascript): normalize erased expression syntax once
This commit is contained in:
1 parent
cfb12e47dc
commit
b628bba1fa
17 files changed
+313
-205
No files matched your search
@@ -390,6 +390,26 @@ describe("semantic expression depth bounds", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("counts erased TypeScript wrappers against expression depth", () => {
|
||||
const parsed = parseJavaScriptSource("const answer = true;");
|
||||
const declaration = parsed?.program.body[0];
|
||||
const declarator = t.isVariableDeclaration(declaration)
|
||||
? declaration.declarations[0]
|
||||
: undefined;
|
||||
if (parsed === null || !t.isVariableDeclarator(declarator))
|
||||
throw new Error("Expected parsed binding initializer");
|
||||
let expression: t.Expression = t.booleanLiteral(true);
|
||||
for (let index = 0; index < 300; index += 1)
|
||||
expression = t.tsAsExpression(expression, t.tsStringKeyword());
|
||||
declarator.init = expression;
|
||||
|
||||
const ir = analyzeParsedJavaScriptSemantics(parsed);
|
||||
expect(topLevelBinding(ir, "answer").value).toMatchObject({
|
||||
status: "unknown",
|
||||
resourceLimit: "expression-depth",
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves exact shallow addition alternatives", () => {
|
||||
expect(valueOf('(choice ? "a" : "b") + (other ? "1" : "2")')).toEqual({
|
||||
status: "union",
|
||||
|
||||
Reference in new issue
Block a user