diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-11 18:11:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-11 18:11:09 +0800 |
commit | f2ad54267945ed96f4e84ade21af262c6ffd1d23 (patch) | |
tree | 353a06c41878545d9e3f71b6b9e03b0f94cc73bf /test | |
parent | c43118be4f8938a3c1d12f836d80c334cba76656 (diff) | |
download | tracifyjs-f2ad54267945ed96f4e84ade21af262c6ffd1d23.tar.gz tracifyjs-f2ad54267945ed96f4e84ade21af262c6ffd1d23.zip |
fix `collapse_vars` on `switch` (#2578)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/collapse_vars.js | 58 |
1 files changed, 57 insertions, 1 deletions
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, |