From 10bf91a293536da270794b5e04650eb922478184 Mon Sep 17 00:00:00 2001 From: davidot Date: Thu, 7 Oct 2021 01:08:19 +0200 Subject: [PATCH] LibJS: Enable now working tests for duplicated variable declarations --- .../Tests/duplicated-variable-declarations.js | 12 ++++++------ Userland/Libraries/LibJS/Tests/var-scoping.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibJS/Tests/duplicated-variable-declarations.js b/Userland/Libraries/LibJS/Tests/duplicated-variable-declarations.js index a371821355..f9b3c4527e 100644 --- a/Userland/Libraries/LibJS/Tests/duplicated-variable-declarations.js +++ b/Userland/Libraries/LibJS/Tests/duplicated-variable-declarations.js @@ -13,14 +13,14 @@ describe("duplicated variable declarations should throw", () => { expect("const b, a; var c, a;").not.toEval(); }); - test.skip("should fail to parse even if variable first declared with var", () => { - expect.skip("var a; let a;").toEval(); - expect.skip("var a; let b, a;").toEval(); - expect.skip("var a; const a;").toEval(); - expect.skip("var a; const b, a;").toEval(); + test("should fail to parse even if variable first declared with var", () => { + expect("var a; let a;").not.toEval(); + expect("var a; let b, a;").not.toEval(); + expect("var a; const a;").not.toEval(); + expect("var a; const b, a;").not.toEval(); }); - test.skip("special cases with for loops", () => { + test("special cases with for loops", () => { expect("for (var a;;) { let a; }").toEval(); expect("for (let a;;) { let a; }").toEval(); expect("for (var a;;) { var a; }").toEval(); diff --git a/Userland/Libraries/LibJS/Tests/var-scoping.js b/Userland/Libraries/LibJS/Tests/var-scoping.js index 86c5f1d5c7..4d3cfd3a2e 100644 --- a/Userland/Libraries/LibJS/Tests/var-scoping.js +++ b/Userland/Libraries/LibJS/Tests/var-scoping.js @@ -15,3 +15,21 @@ test("basic functionality", () => { } expect(caught_exception).not.toBeUndefined(); }); + +test("Issue #8198 arrow function escapes function scope", () => { + const b = 3; + + function f() { + expect(b).toBe(3); + (() => { + expect(b).toBe(3); + var a = "wat"; + eval("var b=a;"); + expect(b).toBe("wat"); + })(); + expect(b).toBe(3); + } + + f(); + expect(b).toBe(3); +});