aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2017-02-24 01:46:57 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-24 01:46:57 +0800
commit4e49302916fe395f5c63992aa28c33392208fb27 (patch)
tree97a15589a105160f71214d548db5fee8202cbb14 /test
parent1e51586996ae4fdac68a8ea597c20ab170809c43 (diff)
downloadtracifyjs-4e49302916fe395f5c63992aa28c33392208fb27.tar.gz
tracifyjs-4e49302916fe395f5c63992aa28c33392208fb27.zip
enable `collapse_vars` & `reduce_vars` by default
- fix corner cases in `const` optimisation - deprecate `/*@const*/` fixes #1497 closes #1498
Diffstat (limited to 'test')
-rw-r--r--test/compress/const.js4
-rw-r--r--test/compress/dead-code.js10
-rw-r--r--test/compress/drop-unused.js31
-rw-r--r--test/compress/evaluate.js1
-rw-r--r--test/compress/issue-1041.js6
5 files changed, 46 insertions, 6 deletions
diff --git a/test/compress/const.js b/test/compress/const.js
index dd175fcc..f1f13f49 100644
--- a/test/compress/const.js
+++ b/test/compress/const.js
@@ -12,6 +12,7 @@ issue_1191: {
join_vars : true,
sequences : false,
collapse_vars : false,
+ reduce_vars : true,
}
input: {
function foo(rot) {
@@ -43,6 +44,7 @@ issue_1194: {
join_vars : true,
sequences : false,
collapse_vars : false,
+ reduce_vars : true,
}
input: {
function f1() {const a = "X"; return a + a;}
@@ -70,6 +72,7 @@ issue_1396: {
join_vars : true,
sequences : false,
collapse_vars : false,
+ reduce_vars : true,
}
input: {
function foo(a) {
@@ -140,6 +143,7 @@ regexp_literal_not_const: {
join_vars : true,
sequences : false,
collapse_vars : false,
+ reduce_vars : true,
}
input: {
(function(){
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index c83f2040..2596e80e 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -94,7 +94,8 @@ dead_code_const_declaration: {
loops : true,
booleans : true,
conditionals : true,
- evaluate : true
+ evaluate : true,
+ reduce_vars : true,
};
input: {
var unused;
@@ -119,7 +120,8 @@ dead_code_const_annotation: {
loops : true,
booleans : true,
conditionals : true,
- evaluate : true
+ evaluate : true,
+ reduce_vars : true,
};
input: {
var unused;
@@ -167,7 +169,8 @@ dead_code_const_annotation_complex_scope: {
loops : true,
booleans : true,
conditionals : true,
- evaluate : true
+ evaluate : true,
+ reduce_vars : true,
};
input: {
var unused_var;
@@ -201,6 +204,5 @@ dead_code_const_annotation_complex_scope: {
var beef = 'good';
var meat = 'beef';
var pork = 'bad';
- 'good' === pork && console.log('reached, not const');
}
}
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index f5a88f21..c1ca1b55 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -648,3 +648,34 @@ drop_value: {
foo(), bar();
}
}
+
+const_assign: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ function f() {
+ const b = 2;
+ return 1 + b;
+ }
+
+ function g() {
+ const b = 2;
+ b = 3;
+ return 1 + b;
+ }
+ }
+ expect: {
+ function f() {
+ return 3;
+ }
+
+ function g() {
+ const b = 2;
+ b = 3;
+ return 1 + b;
+ }
+ }
+}
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index f88bc538..ae5e58d6 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -602,6 +602,7 @@ unsafe_prototype_function: {
call_args: {
options = {
evaluate: true,
+ reduce_vars: true,
}
input: {
const a = 1;
diff --git a/test/compress/issue-1041.js b/test/compress/issue-1041.js
index 9dd176fd..cdbc22cc 100644
--- a/test/compress/issue-1041.js
+++ b/test/compress/issue-1041.js
@@ -13,7 +13,8 @@ const_declaration: {
const_pragma: {
options = {
- evaluate: true
+ evaluate: true,
+ reduce_vars: true,
};
input: {
@@ -27,7 +28,8 @@ const_pragma: {
// for completeness' sake
not_const: {
options = {
- evaluate: true
+ evaluate: true,
+ reduce_vars: true,
};
input: {