aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-07-26 09:44:34 +0100
committerGitHub <noreply@github.com>2021-07-26 16:44:34 +0800
commit9b82f9be9129c98bc02614d15abf957b35778745 (patch)
treee1269e3f718e5e89caf40a22f78a06be6d988ecc /test
parent657d525c80e611df9a78812e4b6a35a3eb24d8f4 (diff)
downloadtracifyjs-9b82f9be9129c98bc02614d15abf957b35778745.tar.gz
tracifyjs-9b82f9be9129c98bc02614d15abf957b35778745.zip
fix corner case in `unused` (#5101)
fixes #5100
Diffstat (limited to 'test')
-rw-r--r--test/compress/rests.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/compress/rests.js b/test/compress/rests.js
index f6878aa8..45d8e222 100644
--- a/test/compress/rests.js
+++ b/test/compress/rests.js
@@ -1003,3 +1003,69 @@ issue_5089_2: {
expect_stdout: "undefined"
node_version: ">=8"
}
+
+issue_5100_1: {
+ options = {
+ passes: 2,
+ pure_getters: "strict",
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var a;
+ [ {
+ p: {},
+ ...a
+ } ] = [ {
+ p: {
+ q: a,
+ } = 42,
+ r: "PASS",
+ } ];
+ console.log(a.r);
+ }
+ expect: {
+ var a;
+ [ {
+ p: {},
+ ...a
+ } ] = [ {
+ p: [ a = 42["q"] ],
+ r: "PASS",
+ } ];
+ console.log(a.r);
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+issue_5100_2: {
+ options = {
+ passes: 2,
+ pure_getters: "strict",
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var a;
+ [ {
+ p: {},
+ ...a
+ } ] = [ {
+ p: (console.log("PASS"), {
+ q: a,
+ } = 42),
+ } ];
+ }
+ expect: {
+ var a;
+ [ {
+ p: {},
+ ...a
+ } ] = [ {
+ p: [ console.log("PASS"), a = 42["q"] ],
+ } ];
+ }
+ expect_stdout: "PASS"
+ node_version: ">=10"
+}