From a9f5b0339dd3c1f8efe87c773b2189139a0d0320 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 16 Sep 2020 23:03:42 +0100 Subject: [PATCH] LibJS: Simplify toEval() implementation --- Libraries/LibJS/Tests/test-common.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Libraries/LibJS/Tests/test-common.js b/Libraries/LibJS/Tests/test-common.js index 7143984d37..1a8e6ce6fe 100644 --- a/Libraries/LibJS/Tests/test-common.js +++ b/Libraries/LibJS/Tests/test-common.js @@ -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