aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-03-03 10:47:17 +0000
committerGitHub <noreply@github.com>2021-03-03 18:47:17 +0800
commit2a49760032dea89032d6bc82dabab5e9e53bb310 (patch)
tree62c3b4078e1eee347029776944500ebd3ec6dbaa /test
parent04ed818f0a53b4ec21887f7d2e44c78a99fd1fa3 (diff)
downloadtracifyjs-2a49760032dea89032d6bc82dabab5e9e53bb310.tar.gz
tracifyjs-2a49760032dea89032d6bc82dabab5e9e53bb310.zip
enhance `side_effects` (#4727)
Diffstat (limited to 'test')
-rw-r--r--test/compress/collapse_vars.js10
-rw-r--r--test/compress/issue-281.js20
-rw-r--r--test/compress/merge_vars.js4
-rw-r--r--test/compress/reduce_vars.js6
-rw-r--r--test/compress/sequences.js8
5 files changed, 27 insertions, 21 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index fe963b4a..c0a545c5 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -2863,7 +2863,7 @@ lvalues_def: {
expect: {
var a = 0, b = 1;
a = b++, b = +void 0;
- a && a[a++];
+ a && a++;
console.log(a, b);
}
expect_stdout: true
@@ -5098,7 +5098,7 @@ issue_2878: {
}
b = f2();
a = 1;
- b && b.b;
+ b && b[console];
f2();
})();
console.log(c);
@@ -5111,7 +5111,7 @@ issue_2878: {
}
b = f2(),
a = 1,
- b && b.b,
+ b && console,
f2();
})(),
console.log(c);
@@ -6546,7 +6546,7 @@ issue_3520: {
(function f() {
c = 0;
var i = void 0;
- var f = f && f[i];
+ var f = f && f[console && i];
})();
a += b;
c && b++;
@@ -6560,7 +6560,7 @@ issue_3520: {
for (var i = 2; --i >= 0;) {
(function() {
c = 0;
- var f = f && f[void 0];
+ var f = f && f[console && void 0];
})();
a += b;
c && b++;
diff --git a/test/compress/issue-281.js b/test/compress/issue-281.js
index 1c339bcd..797f7d9b 100644
--- a/test/compress/issue-281.js
+++ b/test/compress/issue-281.js
@@ -463,15 +463,19 @@ drop_fargs: {
var a = 1;
!function(a_1) {
a++;
- }(a++ + (a && a.var));
+ }(a++ + (a && console.log(a)));
console.log(a);
}
expect: {
var a = 1;
- ++a && a.var, a++;
+ ++a && console.log(a),
+ a++;
console.log(a);
}
- expect_stdout: "3"
+ expect_stdout: [
+ "2",
+ "3",
+ ]
}
keep_fargs: {
@@ -486,13 +490,17 @@ keep_fargs: {
var a = 1;
!function(a_1) {
a++;
- }(a++ + (a && a.var));
+ }(a++ + (a && console.log(a)));
console.log(a);
}
expect: {
var a = 1;
- ++a && a.var, a++;
+ ++a && console.log(a),
+ a++;
console.log(a);
}
- expect_stdout: "3"
+ expect_stdout: [
+ "2",
+ "3",
+ ]
}
diff --git a/test/compress/merge_vars.js b/test/compress/merge_vars.js
index c45f8353..667cacf8 100644
--- a/test/compress/merge_vars.js
+++ b/test/compress/merge_vars.js
@@ -2723,7 +2723,7 @@ issue_4135: {
var c = function() {
var d = 0;
function f() {
- d && d.p;
+ d && d[console];
}
f();
this;
@@ -2735,7 +2735,7 @@ issue_4135: {
0;
a++;
if (!a)
- c = (a++, c = 0, void (c && c.p));
+ c = (a++, c = 0, void (c && console));
var c;
console.log(a, -1, c);
}
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 5ae0884b..110f046a 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -2554,7 +2554,7 @@ side_effects_assign: {
console.log(a);
}
expect: {
- var a = typeof void (a && a.in);
+ var a = "undefined";
console.log(a);
}
expect_stdout: "undefined"
@@ -2595,9 +2595,7 @@ pure_getters_2: {
var a;
var a = a && a.b;
}
- expect: {
- var a = a && a.b;
- }
+ expect: {}
}
pure_getters_3: {
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index b8190366..a9dbc707 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -745,12 +745,12 @@ issue_2062: {
}
input: {
var a = 1;
- if ([ a || a++ + a--, a++ + a--, a && a.var ]);
+ if ([ a || a++ + a--, a++ + a--, a && a[console] ]);
console.log(a);
}
expect: {
var a = 1;
- a || (a++, a--), a++, --a && a.var;
+ a || (a++, a--), a++, --a && console;
console.log(a);
}
expect_stdout: "1"
@@ -1088,7 +1088,7 @@ issue_3490_1: {
if ({
3: function() {
var a;
- return (a && a.p) < this;
+ return (a && a[console]) < this;
}(),
}) c = "PASS";
if (b) while ("" == typeof d);
@@ -1098,7 +1098,7 @@ issue_3490_1: {
var b = 42, c = "FAIL";
if (function() {
var a;
- a && a.p;
+ a && console;
}(), c = "PASS", b) while ("" == typeof d);
console.log(c, b);
}