diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-04-16 17:25:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-16 17:25:39 +0800 |
commit | 44dfa5a318d6df8eff4741a351f24667708a9cab (patch) | |
tree | 3fd18742530459f3b0259c7f609692992a9ea682 /test/compress/reduce_vars.js | |
parent | 251ff1d1af3209af99d37007691acd5a3b771cfb (diff) | |
download | tracifyjs-44dfa5a318d6df8eff4741a351f24667708a9cab.tar.gz tracifyjs-44dfa5a318d6df8eff4741a351f24667708a9cab.zip |
fix variable substitution (#1816)
- let `collapse_vars` take care of value containing any symbols
- improve overhead accounting
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r-- | test/compress/reduce_vars.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index b6f711ad..7621dd4a 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -1995,3 +1995,55 @@ catch_var: { } expect_stdout: "true" } + +issue_1814_1: { + options = { + evaluate: true, + reduce_vars: true, + unused: true, + } + input: { + const a = 42; + !function() { + var b = a; + !function(a) { + console.log(a++, b); + }(0); + }(); + } + expect: { + const a = 42; + !function() { + !function(a) { + console.log(a++, 42); + }(0); + }(); + } + expect_stdout: "0 42" +} + +issue_1814_2: { + options = { + evaluate: true, + reduce_vars: true, + unused: true, + } + input: { + const a = "32"; + !function() { + var b = a + 1; + !function(a) { + console.log(a++, b); + }(0); + }(); + } + expect: { + const a = "32"; + !function() { + !function(a) { + console.log(a++, "321"); + }(0); + }(); + } + expect_stdout: "0 '321'" +} |