From f2ad54267945ed96f4e84ade21af262c6ffd1d23 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 11 Dec 2017 18:11:09 +0800 Subject: fix `collapse_vars` on `switch` (#2578) --- test/compress/collapse_vars.js | 58 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'test/compress/collapse_vars.js') diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index ab86c6b4..2136b2f0 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -1749,7 +1749,7 @@ for_init: { } } -switch_case: { +switch_case_1: { options = { collapse_vars: true, unused: true, @@ -1777,6 +1777,62 @@ switch_case: { } } +switch_case_2: { + options = { + collapse_vars: true, + } + input: { + var a = 1, b = 2; + switch (b++) { + case b: + var c = a; + var a; + break; + } + console.log(a); + } + expect: { + var a = 1, b = 2; + switch (b++) { + case b: + var c = a; + var a; + break; + } + console.log(a); + } + expect_stdout: "1" +} + +switch_case_3: { + options = { + collapse_vars: true, + } + input: { + var a = 1, b = 2; + switch (a) { + case a: + var b; + break; + case b: + break; + } + console.log(b); + } + expect: { + var a = 1, b = 2; + switch (a) { + case a: + var b; + break; + case b: + break; + } + console.log(b); + } + expect_stdout: "2" +} + issue_27: { options = { collapse_vars: true, -- cgit v1.2.3