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

LibJS: Simplify toEval() implementation

This commit is contained in:
Linus Groh 2020-09-16 23:03:42 +01:00 committed by Andreas Kling
parent 5fd87ccd16
commit a9f5b0339d

View file

@ -285,22 +285,13 @@ class ExpectationError extends Error {
toEval() {
this.__expect(typeof this.target === "string");
if (!this.inverted) {
try {
new Function(this.target)();
} catch (e) {
throw new ExpectationError();
}
} else {
let threw;
try {
new Function(this.target)();
threw = false;
} catch (e) {
threw = true;
}
this.__expect(threw);
let threw = false;
try {
new Function(this.target)();
} catch (e) {
threw = true;
}
this.__expect(this.inverted ? threw : !threw);
}
// Must compile regardless of inverted-ness