aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-07-01 04:33:48 +0100
committerGitHub <noreply@github.com>2020-07-01 11:33:48 +0800
commit484d3fd8c77d8d144c97b312cc2be17586fce995 (patch)
treec94ade7131d4a60f62e7909e5abdb27655b6cc3c /test/compress
parent3bf8699f951c32a93414d1ac4c72364e2e282b33 (diff)
downloadtracifyjs-484d3fd8c77d8d144c97b312cc2be17586fce995.tar.gz
tracifyjs-484d3fd8c77d8d144c97b312cc2be17586fce995.zip
fix corner case in `side_effects` (#4009)
fixes #4008
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/side_effects.js66
1 files changed, 65 insertions, 1 deletions
diff --git a/test/compress/side_effects.js b/test/compress/side_effects.js
index 412a38cb..244e3881 100644
--- a/test/compress/side_effects.js
+++ b/test/compress/side_effects.js
@@ -298,7 +298,7 @@ operator_in: {
expect_stdout: "PASS"
}
-issue_3983: {
+issue_3983_1: {
options = {
collapse_vars: true,
conditionals: true,
@@ -323,7 +323,71 @@ issue_3983: {
}
expect: {
var a = "PASS";
+ g();
+ function g() {}
console.log(a);
}
expect_stdout: "PASS"
}
+
+issue_3983_2: {
+ options = {
+ collapse_vars: true,
+ conditionals: true,
+ evaluate: true,
+ inline: true,
+ passes: 2,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = "PASS";
+ function f() {
+ g && g();
+ }
+ f();
+ function g() {
+ 0 ? a : 0;
+ }
+ var b = a;
+ console.log(a);
+ }
+ expect: {
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}
+
+issue_4008: {
+ options = {
+ collapse_vars: true,
+ evaluate: true,
+ inline: true,
+ pure_getters: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ }
+ input: {
+ var a = "PASS";
+ function f(b, b) {
+ console.log(b);
+ }
+ f && f(a && a[a]);
+ console.log(a);
+ }
+ expect: {
+ var a = "PASS";
+ function f(b, b) {
+ console.log(b);
+ }
+ f(a[a]);
+ console.log(a);
+ }
+ expect_stdout: [
+ "undefined",
+ "PASS",
+ ]
+}