From af310ba2d0cd79fbc02d29db2d959367c276b2b9 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 29 Dec 2019 02:50:57 +0000 Subject: fix corner case in `evaluate` (#3654) fixes #3653 --- test/compress/numbers.js | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/compress/numbers.js b/test/compress/numbers.js index c432a435..07e93f60 100644 --- a/test/compress/numbers.js +++ b/test/compress/numbers.js @@ -997,7 +997,7 @@ identity_1: { expect: { 0 + a; a + 0; - -a; + 0 - a; +a; +a; +a; @@ -1023,7 +1023,7 @@ identity_2: { expect: { +!a; +!a; - -!a; + 0 - !a; +!a; +!a; +!a; @@ -1049,7 +1049,7 @@ identity_3: { expect: { --a; --a; - - --a; + 0 - --a; --a; --a; --a; @@ -1057,3 +1057,42 @@ identity_3: { --a; } } + +issue_3653: { + options = { + evaluate: true, + } + input: { + console.log(0 - (console && 0)); + console.log(0 + (0 - (console && 0))); + console.log(0 - (0 - (console && 0))); + console.log(1 * (0 - (console && 0))); + console.log(1 / (0 - (console && 0))); + console.log((0 - (console && 0)) + 0); + console.log((0 - (console && 0)) - 0); + console.log((0 - (console && 0)) * 1); + console.log((0 - (console && 0)) / 1); + } + expect: { + console.log(0 - (console && 0)); + console.log(0 - (console && 0)); + console.log(0 - (0 - (console && 0))); + console.log(0 - (console && 0)); + console.log(1 / (0 - (console && 0))); + console.log(0 - (console && 0)); + console.log(0 - (console && 0)); + console.log(0 - (console && 0)); + console.log(0 - (console && 0)); + } + expect_stdout: [ + "0", + "0", + "0", + "0", + "Infinity", + "0", + "0", + "0", + "0", + ] +} -- cgit v1.2.3