1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

LibJS/Tests: Use canParseSource() for toEval()

We can now enable the "new.target is syntax error outside of function"
test :^)
This commit is contained in:
Linus Groh 2020-11-11 22:16:37 +00:00 committed by Andreas Kling
parent 7fc98a96a9
commit e77202fe0f
4 changed files with 10 additions and 19 deletions

View file

@ -302,14 +302,8 @@ class ExpectationError extends Error {
// Test for syntax errors; target must be a string
toEval() {
this.__expect(typeof this.target === "string");
let threw = false;
try {
new Function(this.target);
} catch (e) {
threw = true;
}
this.__expect(this.inverted ? threw : !threw);
const success = canParseSource(this.target)
this.__expect(this.inverted ? !success : success);
}
// Must compile regardless of inverted-ness