diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-08-09 22:48:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-10 05:48:56 +0800 |
commit | 49670d216bf7eca9218c797d509e149cd8515708 (patch) | |
tree | ba5e747b7918454d13248eeaa5650dd9212c9395 /test/compress/collapse_vars.js | |
parent | e2237d8cd26e27a284c6a564762345e84a365dae (diff) | |
download | tracifyjs-49670d216bf7eca9218c797d509e149cd8515708.tar.gz tracifyjs-49670d216bf7eca9218c797d509e149cd8515708.zip |
fix corner case in `collapse_vars` (#4048)
fixes #4047
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r-- | test/compress/collapse_vars.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index ff6b9a29..7fc4b768 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -8391,3 +8391,59 @@ issue_4040: { } expect_stdout: "PASS" } + +issue_4047_1: { + options = { + collapse_vars: true, + evaluate: true, + inline: true, + reduce_vars: true, + sequences: true, + toplevel: true, + unused: true, + } + input: { + var b = 1; + console.log(+function(a) { + b = a; + (a >>= 0) && console.log("PASS"); + }(--b + (0 !== typeof A))); + } + expect: { + var b = 1; + var a; + console.log((a = --b + ((a = 0) !== typeof A), +void ((a >>= 0) && console.log("PASS")))); + } + expect_stdout: [ + "PASS", + "NaN", + ] +} + +issue_4047_2: { + options = { + collapse_vars: true, + evaluate: true, + inline: true, + passes: 2, + reduce_vars: true, + sequences: true, + toplevel: true, + unused: true, + } + input: { + var b = 1; + console.log(+function(a) { + b = a; + (a >>= 0) && console.log("PASS"); + }(--b + (0 !== typeof A))); + } + expect: { + var a; + console.log((a = +(0 !== typeof A), +void ((a >>= 0) && console.log("PASS")))); + } + expect_stdout: [ + "PASS", + "NaN", + ] +} |