aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-12 21:56:27 +0800
committerGitHub <noreply@github.com>2017-04-12 21:56:27 +0800
commit2244743545e8e5a75b4cce219605588cd29581b1 (patch)
treefc5b7077957e20489fada1b3388e39be2f958404 /test
parent04b89645058d85b8b67bb94fb9e39252160a0959 (diff)
downloadtracifyjs-2244743545e8e5a75b4cce219605588cd29581b1.tar.gz
tracifyjs-2244743545e8e5a75b4cce219605588cd29581b1.zip
convert `AST_Seq` from binary tree to array (#1460)
- rename `AST_Seq` to `AST_Sequence` - raise default sequences_limit from 200 to 800
Diffstat (limited to 'test')
-rw-r--r--test/compress/conditionals.js24
-rw-r--r--test/compress/evaluate.js24
-rw-r--r--test/compress/issue-640.js6
-rw-r--r--test/compress/sequences.js118
4 files changed, 125 insertions, 47 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js
index 200b487f..7a6688ba 100644
--- a/test/compress/conditionals.js
+++ b/test/compress/conditionals.js
@@ -979,12 +979,12 @@ delete_conditional_1: {
console.log(delete (1 ? 0 / 0 : x));
}
expect: {
- console.log((void 0, !0));
- console.log((void 0, !0));
- console.log((1 / 0, !0));
- console.log((1 / 0, !0));
- console.log((NaN, !0));
- console.log((NaN, !0));
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
}
expect_stdout: true
}
@@ -1006,12 +1006,12 @@ delete_conditional_2: {
console.log(delete (0 ? x : 0 / 0));
}
expect: {
- console.log((void 0, !0));
- console.log((void 0, !0));
- console.log((Infinity, !0));
- console.log((1 / 0, !0));
- console.log((NaN, !0));
- console.log((NaN, !0));
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
}
expect_stdout: true
}
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index 611acf0d..585ee2b9 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -922,12 +922,12 @@ delete_binary_1: {
console.log(delete (true && (0 / 0)));
}
expect: {
- console.log((void 0, !0));
- console.log((void 0, !0));
- console.log((1 / 0, !0));
- console.log((1 / 0, !0));
- console.log((NaN, !0));
- console.log((NaN, !0));
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
}
expect_stdout: true
}
@@ -948,12 +948,12 @@ delete_binary_2: {
console.log(delete (false || (0 / 0)));
}
expect: {
- console.log((void 0, !0));
- console.log((void 0, !0));
- console.log((Infinity, !0));
- console.log((1 / 0, !0));
- console.log((NaN, !0));
- console.log((NaN, !0));
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
}
expect_stdout: true
}
diff --git a/test/compress/issue-640.js b/test/compress/issue-640.js
index fbf5f37f..c9a68dc9 100644
--- a/test/compress/issue-640.js
+++ b/test/compress/issue-640.js
@@ -159,7 +159,7 @@ negate_iife_4: {
})();
}
expect: {
- (function(){ return t })() ? console.log(true) : console.log(false), function(){
+ !function(){ return t }() ? console.log(false) : console.log(true), function(){
console.log("something");
}();
}
@@ -183,7 +183,7 @@ negate_iife_5: {
})();
}
expect: {
- (function(){ return t })() ? foo(true) : bar(false), function(){
+ !function(){ return t }() ? bar(false) : foo(true), function(){
console.log("something");
}();
}
@@ -207,7 +207,7 @@ negate_iife_5_off: {
})();
}
expect: {
- (function(){ return t })() ? foo(true) : bar(false), function(){
+ !function(){ return t }() ? bar(false) : foo(true), function(){
console.log("something");
}();
}
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index 699341c0..3fb26278 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -460,7 +460,7 @@ issue_1758: {
console.log(function(c) {
var undefined = 42;
return function() {
- return c--, c--, c.toString(), void 0;
+ return c--, c--, void c.toString();
}();
}());
}
@@ -481,12 +481,12 @@ delete_seq_1: {
console.log(delete (1, 0 / 0));
}
expect: {
- console.log((void 0, !0));
- console.log((void 0, !0));
- console.log((1 / 0, !0));
- console.log((1 / 0, !0));
- console.log((NaN, !0));
- console.log((0 / 0, !0));
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
}
expect_stdout: true
}
@@ -505,12 +505,12 @@ delete_seq_2: {
console.log(delete (1, 2, 0 / 0));
}
expect: {
- console.log((void 0, !0));
- console.log((void 0, !0));
- console.log((1 / 0, !0));
- console.log((1 / 0, !0));
- console.log((NaN, !0));
- console.log((0 / 0, !0));
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
}
expect_stdout: true
}
@@ -530,12 +530,12 @@ delete_seq_3: {
console.log(delete (1, 2, 0 / 0));
}
expect: {
- console.log((void 0, !0));
- console.log((void 0, !0));
- console.log((Infinity, !0));
- console.log((1 / 0, !0));
- console.log((NaN, !0));
- console.log((0 / 0, !0));
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
+ console.log(!0);
}
expect_stdout: true
}
@@ -606,7 +606,85 @@ delete_seq_6: {
}
expect: {
var a;
- console.log((a, !0));
+ console.log(!0);
}
expect_stdout: true
}
+
+side_effects: {
+ options = {
+ sequences: true,
+ side_effects: true,
+ }
+ input: {
+ 0, a(), 1, b(), 2, c(), 3;
+ }
+ expect: {
+ a(), b(), c();
+ }
+}
+
+side_effects_cascade_1: {
+ options = {
+ cascade: true,
+ conditionals: true,
+ sequences: true,
+ side_effects: true,
+ }
+ input: {
+ function f(a, b) {
+ a -= 42;
+ if (a < 0) a = 0;
+ b.a = a;
+ }
+ }
+ expect: {
+ function f(a, b) {
+ (a -= 42) < 0 && (a = 0), b.a = a;
+ }
+ }
+}
+
+side_effects_cascade_2: {
+ options = {
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function f(a, b) {
+ b = a,
+ !a + (b += a) || (b += a),
+ b = a,
+ b;
+ }
+ }
+ expect: {
+ function f(a, b) {
+ b = a,
+ !a + (b += a) || (b += a),
+ b = a;
+ }
+ }
+}
+
+side_effects_cascade_3: {
+ options = {
+ cascade: true,
+ conditionals: true,
+ side_effects: true,
+ }
+ input: {
+ function f(a, b) {
+ "foo" ^ (b += a),
+ b ? false : (b = a) ? -1 : (b -= a) - (b ^= a),
+ a-- || !a,
+ a;
+ }
+ }
+ expect: {
+ function f(a, b) {
+ !(b += a) && ((b = a) || (b -= a, b ^= a)),
+ --a;
+ }
+ }
+}