aboutsummaryrefslogtreecommitdiff
path: root/test/compress/sequences.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress/sequences.js')
-rw-r--r--test/compress/sequences.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index 81b06881..3d12fb0b 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -796,3 +796,66 @@ cascade_assignment_in_return: {
}
}
}
+
+hoist_defun: {
+ options = {
+ join_vars: true,
+ sequences: true,
+ }
+ input: {
+ x();
+ function f() {}
+ y();
+ }
+ expect: {
+ function f() {}
+ x(), y();
+ }
+}
+
+hoist_decl: {
+ options = {
+ join_vars: true,
+ sequences: true,
+ }
+ input: {
+ var a;
+ w();
+ var b = x();
+ y();
+ for (var c; 0;) z();
+ var d;
+ }
+ expect: {
+ var a;
+ w();
+ var b = x(), c, d;
+ for (y(); 0;) z();
+ }
+}
+
+for_init_var: {
+ options = {
+ join_vars: true,
+ unused: false,
+ }
+ input: {
+ var a = "PASS";
+ (function() {
+ var b = 42;
+ for (var c = 5; c > 0;) c--;
+ a = "FAIL";
+ var a;
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = "PASS";
+ (function() {
+ for (var b = 42, c = 5, a; c > 0;) c--;
+ a = "FAIL";
+ })();
+ console.log(a);
+ }
+ expect_stdout: "PASS"
+}