Skip to content

Commit 629cb8a

Browse files
Add test for indirect eval
1 parent 8210f62 commit 629cb8a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/es12/optional-calls.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ const tests = [
164164
fn?.()
165165
`));
166166
},
167+
},
168+
{
169+
name: "Optional call to eval should be indirect eval",
170+
body() {
171+
const x = 2;
172+
const y = 4;
173+
assert.areEqual(6, eval("x + y"));
174+
assert.throws(() => eval?.("x + y"), ReferenceError, "Should not have access to local scope", "'x' is not defined");
175+
}
167176
}
168177
];
169178

0 commit comments

Comments
 (0)