فهرست منبع

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.
Linus Groh 4 سال پیش
والد
کامیت
d278f61f4c
2فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 1 1
      Libraries/LibJS/Tests/test-common-tests.js
  2. 1 1
      Libraries/LibJS/Tests/test-common.js

+ 1 - 1
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();
 });

+ 1 - 1
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;
             }