diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-01-30 00:08:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 00:08:53 +0800 |
commit | a3754068dde7a51ab41b59a6d8a17a3a8c022564 (patch) | |
tree | bbf713958d95e4e5d558f7173959f0dfce7fb48f /test/compress | |
parent | 2ba5f391e008b5d842571094d1140f9ae888ea4d (diff) | |
download | tracifyjs-a3754068dde7a51ab41b59a6d8a17a3a8c022564.tar.gz tracifyjs-a3754068dde7a51ab41b59a6d8a17a3a8c022564.zip |
fix corner case in `collapse_vars` (#3699)
fixes #3698
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 4cd59a4c..f109e93e 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -7658,3 +7658,79 @@ call_3_symbol: { } expect_stdout: "function" } + +issue_3698_1: { + options = { + collapse_vars: true, + } + input: { + var log = console.log; + var a, b = 0, c = 0; + (function() { + a = b; + })(b++, (b++, c++)); + log(a, b, c); + } + expect: { + var log = console.log; + var a, b = 0, c = 0; + (function() { + a = b; + })(b++, (b++, c++)); + log(a, b, c); + } + expect_stdout: "2 2 1" +} + +issue_3698_2: { + options = { + collapse_vars: true, + reduce_vars: true, + } + input: { + var log = console.log; + var a, b = 0, c = 0, d = 1; + (function f() { + a = b; + d-- && f(); + })(b++, (b++, c++)); + log(a, b, c, d); + } + expect: { + var log = console.log; + var a, b = 0, c = 0, d = 1; + (function f() { + a = b; + d-- && f(); + })(b++, (b++, c++)); + log(a, b, c, d); + } + expect_stdout: "2 2 1 -1" +} + +issue_3698_3: { + options = { + collapse_vars: true, + reduce_vars: true, + } + input: { + var a = 0, b = 0; + (function f(c) { + { + b++; + var bar_1 = (b = 1 + b, c = 0); + a-- && f(); + } + })(); + console.log(b); + } + expect: { + var a = 0, b = 0; + (function f(c) { + var bar_1 = (b = 1 + ++b, c = 0); + a-- && f(); + })(); + console.log(b); + } + expect_stdout: "2" +} |