From d278f61f4c63f9904eaf71d2efb37189e8133331 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 27 Oct 2020 23:04:23 +0000 Subject: [PATCH] LibJS: Restrict toEval() failures to SyntaxError We only use expect(...).toEval() / not.toEval() for checking syntax errors, where we obviously can't put the code in a regular function. For runtime errors we do exactly that, so toEval() should not fail - this allows us to use undefined identifiers in syntax tests. --- Libraries/LibJS/Tests/test-common-tests.js | 2 +- Libraries/LibJS/Tests/test-common.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/Tests/test-common-tests.js b/Libraries/LibJS/Tests/test-common-tests.js index a2071f15a0..8dec6e1fb5 100644 --- a/Libraries/LibJS/Tests/test-common-tests.js +++ b/Libraries/LibJS/Tests/test-common-tests.js @@ -330,7 +330,7 @@ test("toThrowWithMessage", () => { // "eval" function test("toEval", () => { expect("let a = 1").toEval(); - expect("a < 1").not.toEval(); + expect("a < 1").toEval(); expect("&&*^%#%@").not.toEval(); expect("function foo() { return 1; }; return foo();").toEval(); }); diff --git a/Libraries/LibJS/Tests/test-common.js b/Libraries/LibJS/Tests/test-common.js index 1a8e6ce6fe..b5a4663246 100644 --- a/Libraries/LibJS/Tests/test-common.js +++ b/Libraries/LibJS/Tests/test-common.js @@ -287,7 +287,7 @@ class ExpectationError extends Error { let threw = false; try { - new Function(this.target)(); + new Function(this.target); } catch (e) { threw = true; }