diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-14 15:32:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-14 15:32:13 +0800 |
commit | 02a6ce07eba11223518a22bce18e209371f78f39 (patch) | |
tree | 167aa7fffefb81314bc29f5b72dcbac18b11401d /test | |
parent | 738fd52bc46c043db4a0cd415671f54b392ee6ac (diff) | |
download | tracifyjs-02a6ce07eba11223518a22bce18e209371f78f39.tar.gz tracifyjs-02a6ce07eba11223518a22bce18e209371f78f39.zip |
improve `reduce_vars` (#2592)
- account for hoisting nature of `var`
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/reduce_vars.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 504ce6f0..108dc0e9 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -4784,3 +4784,57 @@ escape_local_throw: { } expect_stdout: "PASS" } + +inverted_var: { + options = { + evaluate: true, + inline: true, + passes: 3, + reduce_vars: true, + side_effects: true, + unused: true, + } + input: { + console.log(function() { + var a = 1; + return a; + }(), function() { + var b; + b = 2; + return b; + }(), function() { + c = 3; + return c; + var c; + }(), function(c) { + c = 4; + return c; + }(), function (c) { + c = 5; + return c; + var c; + }(), function c() { + c = 6; + return c; + }(), function c() { + c = 7; + return c; + var c; + }(), function() { + c = 8; + return c; + var c = "foo"; + }()); + } + expect: { + console.log(1, 2, 3, 4, 5, function c() { + c = 6; + return c; + }(), 7, function() { + c = 8; + return c; + var c = "foo"; + }()); + } + expect_stdout: true +} |