diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/eval-aliasing.js')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/eval-aliasing.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/eval-aliasing.js b/Userland/Libraries/LibJS/Tests/eval-aliasing.js new file mode 100644 index 0000000000..2779783535 --- /dev/null +++ b/Userland/Libraries/LibJS/Tests/eval-aliasing.js @@ -0,0 +1,15 @@ +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"); +}); |