aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-20 13:06:14 +0800
committerGitHub <noreply@github.com>2017-04-20 13:06:14 +0800
commitf05d4f7af3659a481b06449584fa63e3772322e2 (patch)
tree48af6da99b39bf561a29c452d97325ba7063d386 /test
parent88e7a542cd8a8406f54c53cefe72944452f5e013 (diff)
downloadtracifyjs-f05d4f7af3659a481b06449584fa63e3772322e2.tar.gz
tracifyjs-f05d4f7af3659a481b06449584fa63e3772322e2.zip
improve `unused` (#1832)
- extract leading value with side-effects out of `var` statement - reduce scanning of `AST_Definitions` from 3 passes to just once
Diffstat (limited to 'test')
-rw-r--r--test/compress/collapse_vars.js6
-rw-r--r--test/compress/drop-unused.js3
-rw-r--r--test/compress/reduce_vars.js12
3 files changed, 8 insertions, 13 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 94515a6f..a4c1f9e6 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -701,10 +701,10 @@ collapse_vars_lvalues_drop_assign: {
function f2(x) { var z = x, a = ++z; return z += a; }
function f3(x) { var a = (x -= 3); return x + a; }
function f4(x) { var a = (x -= 3); return x + a; }
- function f5(x) { var v = (e1(), e2()), c = v = --x; return x - c; }
+ function f5(x) { e1(); var v = e2(), c = v = --x; return x - c; }
function f6(x) { e1(), e2(); return --x - x; }
- function f7(x) { var c = (e1(), e2() - x); return x - c; }
- function f8(x) { var v = (e1(), e2()); return x - (v - x); }
+ function f7(x) { e1(); var c = e2() - x; return x - c; }
+ function f8(x) { e1(); var v = e2(); return x - (v - x); }
function f9(x) { e1(); return e2() - x - x; }
}
}
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 8f0aa0bf..7456f676 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -935,7 +935,8 @@ issue_1715_3: {
try {
console;
} catch (a) {
- var a = x();
+ var a;
+ x();
}
}
f();
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index c5f26904..57e23891 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -53,9 +53,7 @@ reduce_vars: {
console.log(-3);
eval("console.log(a);");
})(eval);
- (function() {
- return "yes";
- })();
+ "yes";
console.log(2);
}
expect_stdout: true
@@ -1699,9 +1697,7 @@ redefine_arguments_2: {
console.log(function() {
var arguments;
return typeof arguments;
- }(), function() {
- return"number";
- }(), function(x) {
+ }(), "number", function(x) {
var arguments = x;
return typeof arguments;
}());
@@ -1810,9 +1806,7 @@ redefine_farg_2: {
console.log(function(a) {
var a;
return typeof a;
- }([]), function() {
- return "number";
- }(),function(a, b) {
+ }([]), "number",function(a, b) {
var a = b;
return typeof a;
}([]));