diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-05-01 17:19:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-02 00:19:56 +0800 |
commit | 53b57ee57e3d00792f70685e6b4531e6d990ca27 (patch) | |
tree | 7ea8703b651b2fab948ea5fd53f9154332c3ec26 /test/compress | |
parent | 16411dcb8721e9901271db74c3409e720c2f8ec5 (diff) | |
download | tracifyjs-53b57ee57e3d00792f70685e6b4531e6d990ca27.tar.gz tracifyjs-53b57ee57e3d00792f70685e6b4531e6d990ca27.zip |
enhance `reduce_vars` & `unused` (#4890)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/functions.js | 170 | ||||
-rw-r--r-- | test/compress/ie8.js | 4 |
2 files changed, 172 insertions, 2 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js index a9a3b8f6..5713a37b 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -6013,7 +6013,7 @@ issue_4823: { console.log(typeof function() { { function f() {} - arguments = f(); + f(); var arguments = function() {}; } return f && arguments; @@ -6040,3 +6040,171 @@ drop_unused_self_reference: { } expect_stdout: "PASS" } + +reduce_cross_reference_1: { + options = { + passes: 3, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function(a, b) { + a = b = function() {}; + a.p = a; + b = a = function() {}; + b.q = b; + })(); + } + expect: {} + expect_stdout: true +} + +reduce_cross_reference_1_toplevel: { + options = { + passes: 2, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + var a = b = function() {}; + a.p = a; + var b = a = function() {}; + b.q = b; + } + expect: {} + expect_stdout: true +} + +reduce_cross_reference_2: { + options = { + collapse_vars: true, + passes: 3, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function(a, b) { + a = b = function() {}; + b.p = a; + b = a = function() {}; + a.q = b; + })(); + } + expect: {} + expect_stdout: true +} + +reduce_cross_reference_2_toplevel: { + options = { + collapse_vars: true, + passes: 2, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + var a = b = function() {}; + b.p = a; + var b = a = function() {}; + a.q = b; + } + expect: {} + expect_stdout: true +} + +reduce_cross_reference_3: { + options = { + collapse_vars: true, + passes: 3, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function(a, b) { + a = b = function() {}; + a.p = b; + b = a = function() {}; + b.q = a; + })(); + } + expect: {} + expect_stdout: true +} + +reduce_cross_reference_3_toplevel: { + options = { + collapse_vars: true, + passes: 2, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + var a = b = function() {}; + a.p = b; + var b = a = function() {}; + b.q = a; + } + expect: {} + expect_stdout: true +} + +reduce_cross_reference_4: { + options = { + passes: 3, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function(a, b) { + a = b = function() {}; + b.p = b; + b = a = function() {}; + a.q = a; + })(); + } + expect: {} + expect_stdout: true +} + +reduce_cross_reference_4_toplevel: { + options = { + passes: 2, + pure_getters: "strict", + reduce_vars: true, + sequences: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + var a = b = function() {}; + b.p = b; + var b = a = function() {}; + a.q = a; + } + expect: {} + expect_stdout: true +} diff --git a/test/compress/ie8.js b/test/compress/ie8.js index a1daa59c..23532968 100644 --- a/test/compress/ie8.js +++ b/test/compress/ie8.js @@ -2653,7 +2653,9 @@ issue_4019: { try { console.log("FAIL"); } catch (o) {} - }, o = (console.log(o.length), ++o); + }; + console.log(o.length), + ++o; } expect_stdout: "0" } |