aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-17 17:11:29 +0800
committerGitHub <noreply@github.com>2017-04-17 17:11:29 +0800
commit4ffb6fce7668a1199284e4ce8be91fdaeaf2df0e (patch)
treeb3c15bc9198c44edfb7aae4a87cfa0c61e564b91 /test
parent71a8d0d236d29015df2d1df18de11d661d17af2e (diff)
downloadtracifyjs-4ffb6fce7668a1199284e4ce8be91fdaeaf2df0e.tar.gz
tracifyjs-4ffb6fce7668a1199284e4ce8be91fdaeaf2df0e.zip
compress duplicated variable definitions (#1817)
These are surprisingly common, as people reuse the same variable name within loops or switch branches.
Diffstat (limited to 'test')
-rw-r--r--test/compress/drop-unused.js27
-rw-r--r--test/compress/reduce_vars.js3
2 files changed, 28 insertions, 2 deletions
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 99d9cace..2eefbe8d 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1029,3 +1029,30 @@ delete_assign_2: {
}
expect_stdout: true
}
+
+drop_var: {
+ options = {
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a;
+ console.log(a, b);
+ var a = 1, b = 2;
+ console.log(a, b);
+ var a = 3;
+ console.log(a, b);
+ }
+ expect: {
+ console.log(a, b);
+ var a = 1, b = 2;
+ console.log(a, b);
+ a = 3;
+ console.log(a, b);
+ }
+ expect_stdout: [
+ "undefined undefined",
+ "1 2",
+ "3 2",
+ ]
+}
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 405dbc23..82b00211 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -1639,7 +1639,7 @@ redefine_arguments_1: {
return typeof arguments;
}
function g() {
- return"number";
+ return "number";
}
function h(x) {
var arguments = x;
@@ -1951,7 +1951,6 @@ pure_getters_2: {
var a = a && a.b;
}
expect: {
- var a;
var a = a && a.b;
}
}