aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-25 01:01:45 +0000
committerGitHub <noreply@github.com>2021-02-25 09:01:45 +0800
commit822b1da5d2be26245baa555e75bd70a71d3be506 (patch)
tree1a522fd6bb7502c891633118fdd5b9314a3bd970 /test/compress
parent72805ea73a18a93793b0f3f5c64512a057d46e94 (diff)
downloadtracifyjs-822b1da5d2be26245baa555e75bd70a71d3be506.tar.gz
tracifyjs-822b1da5d2be26245baa555e75bd70a71d3be506.zip
fix corner cases with arrow functions (#4688)
fixes #4687
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/arrows.js81
-rw-r--r--test/compress/classes.js132
2 files changed, 212 insertions, 1 deletions
diff --git a/test/compress/arrows.js b/test/compress/arrows.js
index a3a46871..6cb55223 100644
--- a/test/compress/arrows.js
+++ b/test/compress/arrows.js
@@ -704,7 +704,7 @@ issue_4666: {
node_version: ">=4"
}
-issue_4685: {
+issue_4685_1: {
options = {
collapse_vars: true,
unused: true,
@@ -724,3 +724,82 @@ issue_4685: {
expect_stdout: "PASS"
node_version: ">=4"
}
+
+issue_4685_2: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ new function(f) {
+ if (f() !== this)
+ console.log("PASS");
+ }(() => {
+ if (console)
+ return this;
+ });
+ }
+ expect: {
+ new function(f) {
+ if (f() !== this)
+ console.log("PASS");
+ }(() => {
+ if (console)
+ return this;
+ });
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
+
+issue_4687_1: {
+ options = {
+ collapse_vars: true,
+ unused: true,
+ }
+ input: {
+ new function() {
+ console.log(function(f) {
+ return f() === this;
+ }(() => this) || "PASS");
+ }
+ }
+ expect: {
+ new function() {
+ console.log(function(f) {
+ return f() === this;
+ }(() => this) || "PASS");
+ }
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
+
+issue_4687_2: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ new function() {
+ console.log(function(f) {
+ return f() === this;
+ }(() => {
+ if (console)
+ return this;
+ }) || "PASS");
+ }
+ }
+ expect: {
+ new function() {
+ console.log(function(f) {
+ return f() === this;
+ }(() => {
+ if (console)
+ return this;
+ }) || "PASS");
+ }
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
diff --git a/test/compress/classes.js b/test/compress/classes.js
index 95b4037d..ab2652c8 100644
--- a/test/compress/classes.js
+++ b/test/compress/classes.js
@@ -615,3 +615,135 @@ issue_4683: {
expect_stdout: "PASS"
node_version: ">=4"
}
+
+issue_4685_1: {
+ options = {
+ collapse_vars: true,
+ unused: true,
+ }
+ input: {
+ "use strict";
+ new class {
+ f() {
+ (function(g) {
+ if (g() !== this)
+ console.log("PASS");
+ })(() => this);
+ }
+ }().f();
+ }
+ expect: {
+ "use strict";
+ new class {
+ f() {
+ (function(g) {
+ if (g() !== this)
+ console.log("PASS");
+ })(() => this);
+ }
+ }().f();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
+
+issue_4685_2: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ "use strict";
+ new class {
+ f() {
+ (function(g) {
+ if (g() !== this)
+ console.log("PASS");
+ })(() => {
+ if (console)
+ return this;
+ });
+ }
+ }().f();
+ }
+ expect: {
+ "use strict";
+ new class {
+ f() {
+ (function(g) {
+ if (g() !== this)
+ console.log("PASS");
+ })(() => {
+ if (console)
+ return this;
+ });
+ }
+ }().f();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
+
+issue_4687_1: {
+ options = {
+ collapse_vars: true,
+ unused: true,
+ }
+ input: {
+ "use strict";
+ new class {
+ f() {
+ console.log(function(g) {
+ return g() === this;
+ }(() => this) || "PASS");
+ }
+ }().f();
+ }
+ expect: {
+ "use strict";
+ new class {
+ f() {
+ console.log(function(g) {
+ return g() === this;
+ }(() => this) || "PASS");
+ }
+ }().f();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
+
+issue_4687_2: {
+ options = {
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ "use strict";
+ new class {
+ f() {
+ console.log(function(g) {
+ return g() === this;
+ }(() => {
+ if (console)
+ return this;
+ }) || "PASS");
+ }
+ }().f();
+ }
+ expect: {
+ "use strict";
+ new class {
+ f() {
+ console.log(function(g) {
+ return g() === this;
+ }(() => {
+ if (console)
+ return this;
+ }) || "PASS");
+ }
+ }().f();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}