aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-02-12 23:46:16 +0000
committerGitHub <noreply@github.com>2020-02-12 23:46:16 +0000
commit83a42716c37eb644c490454d7f2119b1fe8158b1 (patch)
tree773bc0657e4965f2358c2c56b254a4b0256661d7 /test
parent2557148bba9e380004c69551aa07f2f424d65159 (diff)
downloadtracifyjs-83a42716c37eb644c490454d7f2119b1fe8158b1.tar.gz
tracifyjs-83a42716c37eb644c490454d7f2119b1fe8158b1.zip
fix corner case in `unused` (#3716)
Diffstat (limited to 'test')
-rw-r--r--test/compress/drop-unused.js52
-rw-r--r--test/compress/functions.js2
-rw-r--r--test/compress/keep_fargs.js8
3 files changed, 50 insertions, 12 deletions
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 0691a180..2d2f3d43 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1191,10 +1191,10 @@ issue_2105_1: {
input: {
!function(factory) {
factory();
- }( function() {
+ }(function() {
return function(fn) {
fn()().prop();
- }( function() {
+ }(function() {
function bar() {
var quux = function() {
console.log("PASS");
@@ -1205,7 +1205,7 @@ issue_2105_1: {
return { prop: foo };
}
return bar;
- } );
+ });
});
}
expect: {
@@ -1235,10 +1235,10 @@ issue_2105_2: {
input: {
!function(factory) {
factory();
- }( function() {
+ }(function() {
return function(fn) {
fn()().prop();
- }( function() {
+ }(function() {
function bar() {
var quux = function() {
console.log("PASS");
@@ -1249,7 +1249,7 @@ issue_2105_2: {
return { prop: foo };
}
return bar;
- } );
+ });
});
}
expect: {
@@ -1258,6 +1258,44 @@ issue_2105_2: {
expect_stdout: "PASS"
}
+issue_2105_3: {
+ options = {
+ inline: true,
+ passes: 2,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ !function(factory) {
+ factory();
+ }(function() {
+ return function(fn) {
+ fn()().prop();
+ }(function() {
+ function bar() {
+ var quux = function() {
+ console.log("PASS");
+ }, foo = function() {
+ console.log;
+ quux();
+ };
+ return { prop: foo };
+ }
+ return bar;
+ });
+ });
+ }
+ expect: {
+ !void void {
+ prop: function() {
+ console.log;
+ void console.log("PASS");
+ }
+ }.prop();
+ }
+ expect_stdout: "PASS"
+}
+
issue_2226_1: {
options = {
side_effects: true,
@@ -2330,7 +2368,7 @@ function_parameter_ie8: {
(function() {
(function f() {
console.log("PASS");
- })(0);
+ })();
})();
}
expect_stdout: "PASS"
diff --git a/test/compress/functions.js b/test/compress/functions.js
index ef51af72..0cf01792 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1276,7 +1276,7 @@ issue_2630_3: {
(function() {
(function f1(a) {
f2();
- --x >= 0 && f1({});
+ --x >= 0 && f1();
})(a++);
function f2() {
a++;
diff --git a/test/compress/keep_fargs.js b/test/compress/keep_fargs.js
index a17a8f3f..85fcb0bf 100644
--- a/test/compress/keep_fargs.js
+++ b/test/compress/keep_fargs.js
@@ -728,7 +728,7 @@ issue_2630_3: {
(function() {
(function f1() {
f2();
- --x >= 0 && f1({});
+ --x >= 0 && f1();
})(a++);
function f2() {
a++;
@@ -1369,7 +1369,7 @@ recursive_iife_1: {
}
expect: {
console.log(function f(a, b) {
- return b || f("FAIL", "PASS");
+ return b || f(0, "PASS");
}());
}
expect_stdout: "PASS"
@@ -1388,7 +1388,7 @@ recursive_iife_2: {
}
expect: {
console.log(function f(a, b) {
- return b || f("FAIL", "PASS");
+ return b || f(0, "PASS");
}(0, 0));
}
expect_stdout: "PASS"
@@ -1416,7 +1416,7 @@ recursive_iife_3: {
var a = 1, c = "PASS";
(function() {
(function f(b, d, e) {
- a-- && f(null, 42, 0);
+ a-- && f(0, 42, 0);
e && (c = "FAIL");
d && d.p;
})();