aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-17 13:58:27 +0800
committerGitHub <noreply@github.com>2018-01-17 13:58:27 +0800
commit79cfac77bdee04021db9f60111f55005919f7b67 (patch)
treecb15ad41971a9825ea40e26631dfa2aa8cbf8836 /test/compress
parent224c14d49d0f007af641b8c7d358814634ea7c5f (diff)
downloadtracifyjs-79cfac77bdee04021db9f60111f55005919f7b67.tar.gz
tracifyjs-79cfac77bdee04021db9f60111f55005919f7b67.zip
extend `join_vars` & `sequences` (#2798)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/properties.js48
-rw-r--r--test/compress/sequences.js18
2 files changed, 62 insertions, 4 deletions
diff --git a/test/compress/properties.js b/test/compress/properties.js
index 7df53d39..933774d5 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -1189,7 +1189,7 @@ join_object_assignments_3: {
expect_stdout: "PASS"
}
-join_object_assignments_4: {
+join_object_assignments_return_1: {
options = {
join_vars: true,
}
@@ -1213,7 +1213,7 @@ join_object_assignments_4: {
expect_stdout: "foo"
}
-join_object_assignments_5: {
+join_object_assignments_return_2: {
options = {
join_vars: true,
}
@@ -1239,7 +1239,7 @@ join_object_assignments_5: {
expect_stdout: "bar"
}
-join_object_assignments_6: {
+join_object_assignments_return_3: {
options = {
join_vars: true,
}
@@ -1271,7 +1271,7 @@ join_object_assignments_6: {
]
}
-join_object_assignments_7: {
+join_object_assignments_for: {
options = {
join_vars: true,
}
@@ -1298,3 +1298,43 @@ join_object_assignments_7: {
"3",
]
}
+
+join_object_assignments_if: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ console.log(function() {
+ var o = {};
+ if (o.a = "PASS") return o.a;
+ }())
+ }
+ expect: {
+ console.log(function() {
+ var o = { a: "PASS" };
+ if (o.a) return o.a;
+ }());
+ }
+ expect_stdout: "PASS"
+}
+
+join_object_assignments_forin: {
+ options = {
+ join_vars: true,
+ }
+ input: {
+ console.log(function() {
+ var o = {};
+ for (var a in o.a = "PASS", o)
+ return o[a];
+ }())
+ }
+ expect: {
+ console.log(function() {
+ var o = { a: "PASS" };
+ for (var a in o)
+ return o[a];
+ }());
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index 3d12fb0b..2c900796 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -859,3 +859,21 @@ for_init_var: {
}
expect_stdout: "PASS"
}
+
+forin: {
+ options = {
+ sequences: true,
+ }
+ input: {
+ var o = [];
+ o.push("PASS");
+ for (var a in o)
+ console.log(o[a]);
+ }
+ expect: {
+ var o = [];
+ for (var a in o.push("PASS"), o)
+ console.log(o[a]);
+ }
+ expect_stdout: "PASS"
+}