ladybird/Userland/Libraries/LibJS/Tests/eval-aliasing.js
Anonymous 2822da8c8f LibJS: Correct behaviour of direct vs. indirect eval
eval only has direct access to the local scope when accessed through
the name eval. This includes locals named eval, because of course it
does.
2021-06-23 09:38:33 +01:00

16 lines
540 B
JavaScript

test("variable named 'eval' pointing to another function calls that function", function () {
var testValue = "inner";
// This breaks prettier as it considers this to be a parse error
// before even trying to do any linting
var eval = () => {
return "wat";
};
expect(eval("testValue")).toEqual("wat");
});
test("variable named 'eval' pointing to real eval works as a direct eval", function () {
var testValue = "inner";
var eval = globalThis.eval;
expect(eval("testValue")).toEqual("inner");
});