aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-07-09 17:28:23 +0100
committerGitHub <noreply@github.com>2021-07-10 00:28:23 +0800
commit450aabaaa036df8735a6c21c847dbba1fe060663 (patch)
tree482e130197ef8f4cbefaa9893e8ef82007db73bd /test
parentea7829daf55f8829cc48466379cc6f6cf3394dbd (diff)
downloadtracifyjs-450aabaaa036df8735a6c21c847dbba1fe060663.tar.gz
tracifyjs-450aabaaa036df8735a6c21c847dbba1fe060663.zip
fix corner cases in `rests` & `unused` (#5063)
Diffstat (limited to 'test')
-rw-r--r--test/compress/rests.js78
1 files changed, 77 insertions, 1 deletions
diff --git a/test/compress/rests.js b/test/compress/rests.js
index bbbcc14b..a22a6b21 100644
--- a/test/compress/rests.js
+++ b/test/compress/rests.js
@@ -491,7 +491,7 @@ drop_rest_array: {
rests: true,
}
input: {
- var [ ...[ a ]] = [ "PASS" ];
+ var [ ...[ a ] ] = [ "PASS" ];
console.log(a);
}
expect: {
@@ -542,6 +542,82 @@ drop_rest_lambda: {
node_version: ">=6"
}
+keep_rest_array: {
+ options = {
+ rests: true,
+ }
+ input: {
+ var [ ...[ ...a ] ] = "PASS";
+ console.log(a.join(""));
+ }
+ expect: {
+ var [ ...a ] = "PASS";
+ console.log(a.join(""));
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}
+
+keep_rest_arrow: {
+ options = {
+ arrows: true,
+ keep_fargs: false,
+ reduce_vars: true,
+ rests: true,
+ }
+ input: {
+ console.log(((...[ ...a ]) => a.join(""))("PASS"));
+ }
+ expect: {
+ console.log(((...a) => a.join(""))("PASS"));
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}
+
+keep_rest_lambda_1: {
+ options = {
+ keep_fargs: false,
+ reduce_vars: true,
+ rests: true,
+ toplevel: true,
+ }
+ input: {
+ function f(...[ ...a ]) {
+ return a.join("");
+ }
+ console.log(f("PASS"), f([ 42 ]));
+ }
+ expect: {
+ function f(...a) {
+ return a.join("");
+ }
+ console.log(f("PASS"), f([ 42 ]));
+ }
+ expect_stdout: "PASS 42"
+ node_version: ">=6"
+}
+
+keep_rest_lambda_2: {
+ options = {
+ unused: true,
+ }
+ input: {
+ function f(...[ ...a ]) {
+ return a.join("");
+ }
+ console.log(f("PASS"), f([ 42 ]));
+ }
+ expect: {
+ function f(...[ ...a ]) {
+ return a.join("");
+ }
+ console.log(f("PASS"), f([ 42 ]));
+ }
+ expect_stdout: "PASS 42"
+ node_version: ">=6"
+}
+
issue_4525_1: {
options = {
arguments: true,