aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-04-25 04:14:21 +0800
committerGitHub <noreply@github.com>2019-04-25 04:14:21 +0800
commita206964c0a69776e498ba838e55d0f85946cd27e (patch)
tree7ed1a96e5ed372099935193d370f8a5150abc2ff /test/compress
parentc56d89f804e852f8678fa7557f781de893c138bf (diff)
downloadtracifyjs-a206964c0a69776e498ba838e55d0f85946cd27e.tar.gz
tracifyjs-a206964c0a69776e498ba838e55d0f85946cd27e.zip
enhance `side_effects` (#3383)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/conditionals.js19
-rw-r--r--test/compress/issue-1639.js13
-rw-r--r--test/compress/sequences.js2
3 files changed, 24 insertions, 10 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js
index 78c0ca24..a208165f 100644
--- a/test/compress/conditionals.js
+++ b/test/compress/conditionals.js
@@ -1416,3 +1416,22 @@ issue_3271: {
}
expect_stdout: "1 1"
}
+
+iife_condition: {
+ options = {
+ conditionals: true,
+ side_effects: true,
+ }
+ input: {
+ if (function() {
+ return console;
+ }())
+ console.log("PASS");
+ }
+ expect: {
+ !function() {
+ return console;
+ }() || console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/compress/issue-1639.js b/test/compress/issue-1639.js
index 80d45a76..1579e06e 100644
--- a/test/compress/issue-1639.js
+++ b/test/compress/issue-1639.js
@@ -1,4 +1,3 @@
-
issue_1639_1: {
options = {
booleans: true,
@@ -12,7 +11,6 @@ issue_1639_1: {
}
input: {
var a = 100, b = 10;
-
var L1 = 5;
while (--L1 > 0) {
if ((--b), false) {
@@ -21,7 +19,6 @@ issue_1639_1: {
}
}
}
-
console.log(a, b);
}
expect: {
@@ -29,7 +26,7 @@ issue_1639_1: {
if (--b, 0) var ignore = 0;
console.log(a, b);
}
- expect_stdout: true
+ expect_stdout: "100 6"
}
issue_1639_2: {
@@ -44,25 +41,23 @@ issue_1639_2: {
}
input: {
var a = 100, b = 10;
-
function f19() {
if (++a, false)
if (a)
if (++a);
}
f19();
-
console.log(a, b);
}
expect: {
var a = 100, b = 10;
function f19() {
- ++a, 0;
+ ++a, 1;
}
f19(),
console.log(a, b);
}
- expect_stdout: true
+ expect_stdout: "101 10"
}
issue_1639_3: {
@@ -84,5 +79,5 @@ issue_1639_3: {
a++,
console.log(a, b);
}
- expect_stdout: true
+ expect_stdout: "101 10"
}
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index 0670ab53..29cede40 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -702,7 +702,7 @@ side_effects_cascade_3: {
}
expect: {
function f(a, b) {
- !(b += a) && ((b = a) || (b -= a, b ^= a)),
+ (b += a) || (b = a) || (b -= a, b ^= a),
a--;
}
}