diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-11-13 07:37:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-13 07:37:42 +0800 |
commit | 49fbe9c5ac090b2082ebd4702772af6ccafa13cd (patch) | |
tree | aaaff78264109b1f0f17bcacab92a9fabe703c36 /test | |
parent | 2ac5086831f17ae93f1cfec9b7375b8ae19915ca (diff) | |
download | tracifyjs-49fbe9c5ac090b2082ebd4702772af6ccafa13cd.tar.gz tracifyjs-49fbe9c5ac090b2082ebd4702772af6ccafa13cd.zip |
fix replacement logic in `collapse_vars` (#2475)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/collapse_vars.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 402bd22b..10735b28 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -3518,3 +3518,63 @@ issue_2436_12: { } } } + +issue_2436_13: { + options = { + collapse_vars: true, + reduce_vars: true, + unused: true, + } + input: { + var a = "PASS"; + (function() { + function f(b) { + (function g(b) { + var b = b && (b.null = "FAIL"); + })(a); + } + f(); + })(); + console.log(a); + } + expect: { + var a = "PASS"; + (function() { + (function(b) { + (function(b) { + a && (a.null = "FAIL"); + })(); + })(); + })(); + console.log(a); + } + expect_stdout: "PASS" +} + +issue_2436_14: { + options = { + collapse_vars: true, + reduce_vars: true, + unused: true, + } + input: { + var a = "PASS"; + var b = {}; + (function() { + var c = a; + c && function(c, d) { + console.log(c, d); + }(b, c); + })(); + } + expect: { + var a = "PASS"; + var b = {}; + (function() { + a && function(c, d) { + console.log(c, d); + }(b, a); + })(); + } + expect_stdout: true +} |