diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-07-02 01:05:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-02 01:05:14 +0800 |
commit | d40950b741d67bafc91a102ce2c6e862af46fd11 (patch) | |
tree | 491155594137356177a2acedb3fd0287fcf193b3 /test/compress | |
parent | 7659ea1d2edd7603bd355eb849bd5dd62c3350c7 (diff) | |
download | tracifyjs-d40950b741d67bafc91a102ce2c6e862af46fd11.tar.gz tracifyjs-d40950b741d67bafc91a102ce2c6e862af46fd11.zip |
improve `inline` efficiency (#2188)
... by teaching `collapse_vars` some new tricks.
fixes #2187
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 35 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 5 | ||||
-rw-r--r-- | test/compress/functions.js | 6 | ||||
-rw-r--r-- | test/compress/issue-281.js | 24 |
4 files changed, 55 insertions, 15 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 158d1b4a..f3eb7816 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -1978,10 +1978,10 @@ chained_3: { } expect: { console.log(function(a, b) { - var c = a, c = b; + var c = 1, c = b; b++; return c; - }(1, 2)); + }(0, 2)); } expect_stdout: "2" } @@ -2186,3 +2186,34 @@ compound_assignment: { } expect_stdout: "4" } + +issue_2187: { + options = { + collapse_vars: true, + unused: true, + } + input: { + var a = 1; + !function(foo) { + foo(); + var a = 2; + console.log(a); + }(function() { + console.log(a); + }); + } + expect: { + var a = 1; + !function(foo) { + foo(); + var a = 2; + console.log(a); + }(function() { + console.log(a); + }); + } + expect_stdout: [ + "1", + "2", + ] +} diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index 08fc7b18..e1acdc10 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -1113,6 +1113,7 @@ issue_2105: { options = { collapse_vars: true, inline: true, + passes: 2, reduce_vars: true, side_effects: true, unused: true, @@ -1138,7 +1139,7 @@ issue_2105: { }); } expect: { - !void function() { + (function() { var quux = function() { console.log("PASS"); }; @@ -1148,7 +1149,7 @@ issue_2105: { quux(); } }; - }().prop(); + })().prop(); } expect_stdout: "PASS" } diff --git a/test/compress/functions.js b/test/compress/functions.js index c8efc12c..f411afa2 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -468,11 +468,9 @@ issue_2114_1: { } expect: { var c = 0; - !function() { - 0; - }((c += 1, c = 1 + c, function() { + c = 1 + (c += 1), function() { var b = void (b && (b.b += (c += 1, 0))); - }())); + }(); console.log(c); } expect_stdout: "2" diff --git a/test/compress/issue-281.js b/test/compress/issue-281.js index 9b8c8bfd..65871a84 100644 --- a/test/compress/issue-281.js +++ b/test/compress/issue-281.js @@ -419,7 +419,7 @@ wrap_iife_in_return_call: { expect_exact: '(void console.log("test"))();' } -pure_annotation: { +pure_annotation_1: { options = { inline: true, side_effects: true, @@ -432,6 +432,20 @@ pure_annotation: { expect_exact: "" } +pure_annotation_2: { + options = { + collapse_vars: true, + inline: true, + side_effects: true, + } + input: { + /*@__PURE__*/(function(n) { + console.log("hello", n); + }(42)); + } + expect_exact: "" +} + drop_fargs: { options = { cascade: true, @@ -449,9 +463,7 @@ drop_fargs: { } expect: { var a = 1; - !function() { - a++; - }(++a && a.var); + ++a && a.var, a++; console.log(a); } expect_stdout: "3" @@ -474,9 +486,7 @@ keep_fargs: { } expect: { var a = 1; - !function(a_1) { - a++; - }(++a && a.var); + ++a && a.var, a++; console.log(a); } expect_stdout: "3" |