Ver código fonte

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 anos atrás
pai
commit
d278f61f4c

+ 1 - 1
Libraries/LibJS/Tests/test-common-tests.js

@@ -330,7 +330,7 @@ test("toThrowWithMessage", () => {
 // "eval" function
 // "eval" function
 test("toEval", () => {
 test("toEval", () => {
     expect("let a = 1").toEval();
     expect("let a = 1").toEval();
-    expect("a < 1").not.toEval();
+    expect("a < 1").toEval();
     expect("&&*^%#%@").not.toEval();
     expect("&&*^%#%@").not.toEval();
     expect("function foo() { return 1; }; return foo();").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;
             let threw = false;
             try {
             try {
-                new Function(this.target)();
+                new Function(this.target);
             } catch (e) {
             } catch (e) {
                 threw = true;
                 threw = true;
             }
             }