mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 12:57:35 +00:00
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.
This commit is contained in:
parent
3ec19ae4b6
commit
d278f61f4c
2 changed files with 2 additions and 2 deletions
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue