diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-07-07 03:29:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-07 10:29:16 +0800 |
commit | 0c48b84540d0a19c41ecdb48c2ad5ea4c31c5acc (patch) | |
tree | a26bb4d04e86cb3b5f56653db2b971b22939f5ef /test/compress | |
parent | 1fefe3f1d138f2a1dd9386e02c58f60635632611 (diff) | |
download | tracifyjs-0c48b84540d0a19c41ecdb48c2ad5ea4c31c5acc.tar.gz tracifyjs-0c48b84540d0a19c41ecdb48c2ad5ea4c31c5acc.zip |
fix corner cases in `inline` & `unused` (#5058)
fixes #5057
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/default-values.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/compress/default-values.js b/test/compress/default-values.js index 6406d4a2..ec6a4ea5 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -1416,6 +1416,7 @@ issue_4502_1: { expect: { (function() { var a = "PASS"; + void 0, console.log(a), a++, void 0; @@ -1439,6 +1440,7 @@ issue_4502_2: { expect: { (function() { var a = "PASS"; + void 0, console.log(a), a++, void 0; @@ -1754,3 +1756,78 @@ issue_4994: { expect_stdout: "PASS" node_version: ">=6" } + +issue_5057_1: { + options = { + collapse_vars: true, + inline: true, + sequences: true, + unused: true, + } + input: { + var a = 42; + (function() { + var b = function(c = (console.log("foo"), b = a)) { + a && console.log("bar"); + }(); + })(); + } + expect: { + var a = 42; + console.log("foo"), + void (a && console.log("bar")); + } + expect_stdout: [ + "foo", + "bar", + ] + node_version: ">=6" +} + +issue_5057_2: { + options = { + inline: true, + unused: true, + } + input: { + (function f(a) { + (function(b = console.log("FAIL")) {})(a); + })(42); + console.log(typeof b); + } + expect: { + (function(a) { + [ b = console.log("FAIL") ] = [ a ], + void 0; + var b; + })(42); + console.log(typeof b); + } + expect_stdout: "undefined" + node_version: ">=6" +} + +issue_5057_3: { + options = { + inline: true, + unused: true, + } + input: { + (function(a) { + (function f(b) { + (function(a = console.log("FAIL 1")) {})(b); + console.log(a); + })("FAIL 2"); + })("PASS"); + } + expect: { + (function(a) { + (function(b) { + (function(a = console.log("FAIL 1")) {})(b); + console.log(a); + })("FAIL 2"); + })("PASS"); + } + expect_stdout: "PASS" + node_version: ">=6" +} |