From 8d2151662355a05f1e2fde864168cfddd8eedcda Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 16 Jan 2021 08:55:10 +0000 Subject: fix corner cases in `reduce_vars` (#4561) fixes #4560 --- test/compress/spreads.js | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'test/compress') diff --git a/test/compress/spreads.js b/test/compress/spreads.js index 7c98fdcd..7eac2482 100644 --- a/test/compress/spreads.js +++ b/test/compress/spreads.js @@ -846,3 +846,75 @@ issue_4556: { expect_stdout: "undefined" node_version: ">=6" } + +issue_4560_1: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + var a = 0; + (function(...{ + [a++]: {}, + }) {})(2); + console.log(a); + } + expect: { + var a = 0; + (function(...{ + [a++]: {}, + }) {})(2); + console.log(a); + } + expect_stdout: "1" + node_version: ">=6" +} + +issue_4560_2: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var a = 0; + (function(...{ + [a++]: {}, + }) {})(2); + console.log(a); + } + expect: { + var a = 0; + (function(...{ + [a++]: {}, + }) {})(2); + console.log(a); + } + expect_stdout: "1" + node_version: ">=6" +} + +issue_4560_3: { + options = { + collapse_vars: true, + reduce_vars: true, + toplevel: true, + } + input: { + var a = 0, b; + [ ...{ + [a++]: b, + } ] = [ "PASS" ]; + console.log(b); + } + expect: { + var a = 0, b; + [ ...{ + [a++]: b, + } ] = [ "PASS" ]; + console.log(b); + } + expect_stdout: "PASS" + node_version: ">=6" +} -- cgit v1.2.3