aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/collapse_vars.js21
-rw-r--r--test/compress/functions.js36
2 files changed, 51 insertions, 6 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 22a8d7ae..470f3b76 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -6157,3 +6157,24 @@ sub_property: {
}
expect_stdout: "PASS"
}
+
+assign_undeclared: {
+ options = {
+ collapse_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var A = (console.log(42), function() {});
+ B = new A();
+ console.log(typeof B);
+ }
+ expect: {
+ B = new (console.log(42), function() {})();
+ console.log(typeof B);
+ }
+ expect_stdout: [
+ "42",
+ "object",
+ ]
+}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 983d7068..e12ce3e2 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -3003,12 +3003,10 @@ issue_3366: {
f();
}
expect: {
- (function() {
- function a() {}
- (function() {
- this && a && console.log("PASS");
- })();
- })();
+ void function() {
+ this && a && console.log("PASS");
+ }();
+ function a() {}
}
expect_stdout: "PASS"
}
@@ -3041,3 +3039,29 @@ issue_3371: {
}
expect_stdout: "function"
}
+
+class_iife: {
+ options = {
+ inline: true,
+ sequences: true,
+ toplevel: true,
+ }
+ input: {
+ var A = function() {
+ function B() {}
+ B.prototype.m = function() {
+ console.log("PASS");
+ };
+ return B;
+ }();
+ new A().m();
+ }
+ expect: {
+ var A = (B.prototype.m = function() {
+ console.log("PASS");
+ }, B);
+ function B() {}
+ new A().m();
+ }
+ expect_stdout: "PASS"
+}