mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibJS: Simplify toEval() implementation
This commit is contained in:
parent
5fd87ccd16
commit
a9f5b0339d
1 changed files with 6 additions and 15 deletions
|
@ -285,22 +285,13 @@ class ExpectationError extends Error {
|
||||||
toEval() {
|
toEval() {
|
||||||
this.__expect(typeof this.target === "string");
|
this.__expect(typeof this.target === "string");
|
||||||
|
|
||||||
if (!this.inverted) {
|
let threw = false;
|
||||||
try {
|
try {
|
||||||
new Function(this.target)();
|
new Function(this.target)();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new ExpectationError();
|
threw = true;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let threw;
|
|
||||||
try {
|
|
||||||
new Function(this.target)();
|
|
||||||
threw = false;
|
|
||||||
} catch (e) {
|
|
||||||
threw = true;
|
|
||||||
}
|
|
||||||
this.__expect(threw);
|
|
||||||
}
|
}
|
||||||
|
this.__expect(this.inverted ? threw : !threw);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must compile regardless of inverted-ness
|
// Must compile regardless of inverted-ness
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue