diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-04-21 09:49:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-21 09:49:07 +0800 |
commit | f01cc1e413990a2da37716fbe8627d651f489fff (patch) | |
tree | 9ff84e40e7fabfb16d0fd63af9d4ead6bee72d02 /test/compress | |
parent | 338dd144b8fedd91f0fd33c068984877527614cc (diff) | |
download | tracifyjs-f01cc1e413990a2da37716fbe8627d651f489fff.tar.gz tracifyjs-f01cc1e413990a2da37716fbe8627d651f489fff.zip |
unwind IIFE class patterns (#3373)
fixes #2332
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 21 | ||||
-rw-r--r-- | test/compress/functions.js | 36 |
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" +} |