aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-01-29 08:52:20 +0800
committerGitHub <noreply@github.com>2020-01-29 08:52:20 +0800
commit2ba5f391e008b5d842571094d1140f9ae888ea4d (patch)
treeffd937e18a4efbda9b771463a3de0d58d2e30ddf /test/compress
parent87119e44a08118bf302a4da6ae71e74f8bea4f89 (diff)
downloadtracifyjs-2ba5f391e008b5d842571094d1140f9ae888ea4d.tar.gz
tracifyjs-2ba5f391e008b5d842571094d1140f9ae888ea4d.zip
enhance `collapse_vars` (#3697)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/collapse_vars.js167
1 files changed, 167 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index c3832d43..4cd59a4c 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -7491,3 +7491,170 @@ issue_3671: {
}
expect_stdout: "1"
}
+
+call_1: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ (function(a) {
+ a = console;
+ (function() {})();
+ a.log("PASS");
+ })();
+ }
+ expect: {
+ (function(a) {
+ (function() {})();
+ (a = console).log("PASS");
+ })();
+ }
+ expect_stdout: "PASS"
+}
+
+call_1_symbol: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ }
+ input: {
+ (function(a) {
+ function f() {}
+ a = console;
+ f();
+ a.log(typeof f);
+ })();
+ }
+ expect: {
+ (function(a) {
+ function f() {}
+ f();
+ (a = console).log(typeof f);
+ })();
+ }
+ expect_stdout: "function"
+}
+
+call_2: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ (function(a) {
+ a = console;
+ (function() {
+ return 42;
+ console.log("FAIL");
+ })();
+ a.log("PASS");
+ })();
+ }
+ expect: {
+ (function(a) {
+ (function() {
+ return 42;
+ console.log("FAIL");
+ })();
+ (a = console).log("PASS");
+ })();
+ }
+ expect_stdout: "PASS"
+}
+
+call_2_symbol: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ }
+ input: {
+ (function(a) {
+ function f() {
+ return 42;
+ console.log("FAIL");
+ }
+ a = console;
+ f();
+ a.log(typeof f);
+ })();
+ }
+ expect: {
+ (function(a) {
+ function f() {
+ return 42;
+ console.log("FAIL");
+ }
+ f();
+ (a = console).log(typeof f);
+ })();
+ }
+ expect_stdout: "function"
+}
+
+call_3: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ (function(a) {
+ a = console;
+ (function() {
+ a = {
+ log: function() {
+ console.log("PASS");
+ }
+ }
+ })();
+ a.log("FAIL");
+ })();
+ }
+ expect: {
+ (function(a) {
+ a = console;
+ (function() {
+ a = {
+ log: function() {
+ console.log("PASS");
+ }
+ }
+ })();
+ a.log("FAIL");
+ })();
+ }
+ expect_stdout: "PASS"
+}
+
+call_3_symbol: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ }
+ input: {
+ (function(a) {
+ function f() {
+ a = {
+ log: function() {
+ console.log(typeof f);
+ }
+ }
+ }
+ a = console;
+ f();
+ a.log("FAIL");
+ })();
+ }
+ expect: {
+ (function(a) {
+ function f() {
+ a = {
+ log: function() {
+ console.log(typeof f);
+ }
+ }
+ }
+ a = console;
+ f();
+ a.log("FAIL");
+ })();
+ }
+ expect_stdout: "function"
+}