From be1f5199f422080a42e962670758bd68f34b5bb6 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 26 Dec 2020 05:40:31 +0000 Subject: fix corner cases in `collapse_vars` (#4462) fixes #4460 fixes #4461 --- test/compress/default-values.js | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'test/compress') diff --git a/test/compress/default-values.js b/test/compress/default-values.js index eefa6e0e..0e05d37d 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -1100,3 +1100,63 @@ issue_4458: { expect_stdout: "PASS 42" node_version: ">=6" } + +issue_4460: { + options = { + collapse_vars: true, + } + input: { + var log = console.log, a = "FAIL"; + var [ b = a ] = (a = "PASS", []); + log(a, b); + } + expect: { + var log = console.log, a = "FAIL"; + var [ b = a ] = (a = "PASS", []); + log(a, b); + } + expect_stdout: "PASS PASS" + node_version: ">=6" +} + +issue_4461_1: { + options = { + collapse_vars: true, + unused: true, + } + input: { + var a = 0; + (function(b = a && console.log("PASS"), c) { + return c; + })(void 0, a++); + } + expect: { + var a = 0; + (function(b = a && console.log("PASS"), c) { + return c; + })(void 0, a++); + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_4461_2: { + options = { + collapse_vars: true, + unused: true, + } + input: { + var a = 0; + (function([ b = a && console.log("PASS") ], c) { + return c; + })([], a++); + } + expect: { + var a = 0; + (function([ b = a && console.log("PASS") ], c) { + return c; + })([], a++); + } + expect_stdout: "PASS" + node_version: ">=6" +} -- cgit v1.2.3