mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 18:17:23 +00:00
LibJS: Simplify toEval() implementation
This commit is contained in:
parent
5fd87ccd16
commit
a9f5b0339d
Notes:
sideshowbarker
2024-07-19 02:21:19 +09:00
Author: https://github.com/linusg
Commit: a9f5b0339d
Pull-request: https://github.com/SerenityOS/serenity/pull/3539
1 changed files with 6 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue