aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-24 03:00:47 +0000
committerGitHub <noreply@github.com>2021-01-24 11:00:47 +0800
commita36c5472d2cf9f79ca5245e9299a011ec7e4cef1 (patch)
tree1a32877a16ab2d10a89a619521ef1185a7964406 /test/compress
parent8bfd891c09edfb54d1b93010487ee68ad64a457c (diff)
downloadtracifyjs-a36c5472d2cf9f79ca5245e9299a011ec7e4cef1.tar.gz
tracifyjs-a36c5472d2cf9f79ca5245e9299a011ec7e4cef1.zip
fix corner cases with default parameters (#4589)
fixes #4588
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/default-values.js71
1 files changed, 68 insertions, 3 deletions
diff --git a/test/compress/default-values.js b/test/compress/default-values.js
index 6fc2d3f5..ac89b1ed 100644
--- a/test/compress/default-values.js
+++ b/test/compress/default-values.js
@@ -161,6 +161,7 @@ process_boolean_returns: {
collapse_value_1: {
options = {
collapse_vars: true,
+ keep_fargs: false,
unused: true,
}
input: {
@@ -169,7 +170,7 @@ collapse_value_1: {
}());
}
expect: {
- console.log(function(a) {
+ console.log(function() {
return "PASS";
}());
}
@@ -180,6 +181,7 @@ collapse_value_1: {
collapse_value_2: {
options = {
collapse_vars: true,
+ keep_fargs: false,
unused: true,
}
input: {
@@ -188,7 +190,7 @@ collapse_value_2: {
})().log("PASS");
}
expect: {
- (function(a) {
+ (function() {
return console;
})().log("PASS");
}
@@ -554,8 +556,9 @@ drop_fargs: {
"bar",
]
expect_warnings: [
- "WARN: Dropping unused function argument c [test/compress/default-values.js:1,61]",
+ "WARN: Dropping unused default argument c [test/compress/default-values.js:1,61]",
"WARN: Side effects in default value of unused variable b [test/compress/default-values.js:1,37]",
+ "WARN: Dropping unused default argument assignment a [test/compress/default-values.js:1,29]",
]
node_version: ">=6"
}
@@ -1596,3 +1599,65 @@ issue_4548: {
]
node_version: ">=6"
}
+
+issue_4588_1_unused: {
+ options = {
+ unused: true,
+ }
+ input: {
+ console.log(function(a = 42) {}.length);
+ }
+ expect: {
+ console.log(function(a = 0) {}.length);
+ }
+ expect_stdout: "0"
+ node_version: ">=6"
+}
+
+issue_4588_2_unused: {
+ options = {
+ unused: true,
+ }
+ input: {
+ console.log(function(a, b = void 0, c, d = "foo") {}.length);
+ }
+ expect: {
+ console.log(function(a, b = 0, c, d) {}.length);
+ }
+ expect_stdout: "1"
+ expect_warnings: [
+ "WARN: Dropping unused default argument assignment d [test/compress/default-values.js:1,47]",
+ "WARN: Dropping unused default argument value b [test/compress/default-values.js:1,32]",
+ ]
+ node_version: ">=6"
+}
+
+issue_4588_1_evaluate: {
+ options = {
+ evaluate: true,
+ unsafe: true,
+ }
+ input: {
+ console.log(function(a = 42) {}.length);
+ }
+ expect: {
+ console.log(0);
+ }
+ expect_stdout: "0"
+ node_version: ">=6"
+}
+
+issue_4588_2_evaluate: {
+ options = {
+ evaluate: true,
+ unsafe: true,
+ }
+ input: {
+ console.log(function(a, b = void 0, c, d = "foo") {}.length);
+ }
+ expect: {
+ console.log(1);
+ }
+ expect_stdout: "1"
+ node_version: ">=6"
+}