fix corner case in `unused` (#5190)
[UglifyJS.git] / test / compress / destructured.js
1 redefine_arguments_1: {
2     options = {
3         toplevel: false,
4         unused: true,
5     }
6     input: {
7         function f([ arguments ]) {}
8     }
9     expect: {
10         function f([]) {}
11     }
12     expect_stdout: true
13     node_version: ">=8"
14 }
15
16 redefine_arguments_1_toplevel: {
17     options = {
18         toplevel: true,
19         unused: true,
20     }
21     input: {
22         function f([ arguments ]) {}
23     }
24     expect: {}
25     expect_stdout: true
26     node_version: ">=8"
27 }
28
29 redefine_arguments_2: {
30     options = {
31         side_effects: true,
32     }
33     input: {
34         (function([], arguments) {});
35     }
36     expect: {}
37     expect_stdout: true
38     node_version: ">=8"
39 }
40
41 redefine_arguments_3: {
42     options = {
43         keep_fargs: false,
44         unused: true,
45     }
46     input: {
47         (function([], arguments) {})([]);
48     }
49     expect: {
50         (function() {})();
51     }
52     expect_stdout: true
53     node_version: ">=8"
54 }
55
56 redefine_arguments_4: {
57     options = {
58         toplevel: true,
59         unused: true,
60     }
61     input: {
62         function f() {
63             (function({}, arguments) {});
64         }
65     }
66     expect: {}
67     expect_stdout: true
68     node_version: ">=8"
69 }
70
71 uses_arguments_1_merge_vars: {
72     options = {
73         merge_vars: true,
74     }
75     input: {
76         console.log(typeof function({}) {
77             return arguments;
78         }(42));
79     }
80     expect: {
81         console.log(typeof function({}) {
82             return arguments;
83         }(42));
84     }
85     expect_stdout: "object"
86     node_version: ">=6"
87 }
88
89 uses_arguments_1_unused: {
90     options = {
91         unused: true,
92     }
93     input: {
94         console.log(typeof function({}) {
95             return arguments;
96         }(42));
97     }
98     expect: {
99         console.log(typeof function({}) {
100             return arguments;
101         }(42));
102     }
103     expect_stdout: "object"
104     node_version: ">=6"
105 }
106
107 uses_arguments_2: {
108     options = {
109         collapse_vars: true,
110         reduce_vars: true,
111     }
112     input: {
113         console.log(typeof function({ a }) {
114             a[1] = 2;
115             return arguments;
116         }({ a: 42 }));
117     }
118     expect: {
119         console.log(typeof function({ a }) {
120             a[1] = 2;
121             return arguments;
122         }({ a: 42 }));
123     }
124     expect_stdout: "object"
125     node_version: ">=6"
126 }
127
128 funarg_merge_vars_1: {
129     options = {
130         merge_vars: true,
131     }
132     input: {
133         function f(a, {
134             [a]: b
135         }) {
136             console.log(b);
137         }
138         f(0, [ "PASS" ]);
139     }
140     expect: {
141         function f(a, {
142             [a]: b
143         }) {
144             console.log(b);
145         }
146         f(0, [ "PASS" ]);
147     }
148     expect_stdout: "PASS"
149     node_version: ">=6"
150 }
151
152 funarg_merge_vars_2: {
153     options = {
154         merge_vars: true,
155     }
156     input: {
157         var a = 0;
158         (function f({
159             [a]: b,
160         }) {
161             var a = typeof b;
162             console.log(a);
163         })([ 42 ]);
164     }
165     expect: {
166         var a = 0;
167         (function f({
168             [a]: b,
169         }) {
170             var a = typeof b;
171             console.log(a);
172         })([ 42 ]);
173     }
174     expect_stdout: "number"
175     node_version: ">=6"
176 }
177
178 funarg_side_effects_1: {
179     options = {
180         side_effects: true,
181     }
182     input: {
183         try {
184             (function({}) {})();
185         } catch (e) {
186             console.log("PASS");
187         }
188     }
189     expect: {
190         try {
191             [ {} ] = [];
192         } catch (e) {
193             console.log("PASS");
194         }
195     }
196     expect_stdout: "PASS"
197     node_version: ">=6"
198 }
199
200 funarg_side_effects_2: {
201     options = {
202         side_effects: true,
203     }
204     input: {
205         try {
206             (function({
207                 [(a, 0)]: a,
208             }) {})(1);
209         } catch (e) {
210             console.log("PASS");
211         }
212     }
213     expect: {
214         try {
215             (function({
216                 [(a, 0)]: a,
217             }) {})(1);
218         } catch (e) {
219             console.log("PASS");
220         }
221     }
222     expect_stdout: "PASS"
223     node_version: ">=6"
224 }
225
226 funarg_side_effects_3: {
227     options = {
228         side_effects: true,
229     }
230     input: {
231         try {
232             (function({
233                 p: {
234                     [(a, 0)]: a,
235                 },
236             }) {})({
237                 p: 1,
238             });
239         } catch (e) {
240             console.log("PASS");
241         }
242     }
243     expect: {
244         try {
245             (function({
246                 p: {
247                     [(a, 0)]: a,
248                 },
249             }) {})({
250                 p: 1,
251             });
252         } catch (e) {
253             console.log("PASS");
254         }
255     }
256     expect_stdout: "PASS"
257     node_version: ">=6"
258 }
259
260 funarg_unused_1: {
261     options = {
262         keep_fargs: false,
263         unused: true,
264     }
265     input: {
266         (function([]) {})([ console.log("PASS") ]);
267     }
268     expect: {
269         (function() {})(console.log("PASS"));
270     }
271     expect_stdout: "PASS"
272     node_version: ">=6"
273 }
274
275 funarg_unused_2: {
276     options = {
277         unused: true,
278     }
279     input: {
280         function f([ a, b, c ]) {
281             console.log(b);
282         }
283         f([ "FAIL", "PASS" ]);
284     }
285     expect: {
286         function f([ , b ]) {
287             console.log(b);
288         }
289         f([ "FAIL", "PASS" ]);
290     }
291     expect_stdout: "PASS"
292     node_version: ">=6"
293 }
294
295 funarg_unused_3: {
296     options = {
297         objects: true,
298         evaluate: true,
299         unused: true,
300     }
301     input: {
302         function f({
303             [0]: a,
304         }) {
305             return "PASS";
306         }
307         console.log(f([ "FAIL" ]));
308     }
309     expect: {
310         function f({}) {
311             return "PASS";
312         }
313         console.log(f([ "FAIL" ]));
314     }
315     expect_stdout: "PASS"
316     node_version: ">=6"
317 }
318
319 funarg_unused_4: {
320     options = {
321         keep_fargs: false,
322         pure_getters: "strict",
323         unused: true,
324     }
325     input: {
326         console.log(function([ a ], { b }, c) {
327             return "PASS";
328         }([ 1 ], { b: 2 }, 3));
329     }
330     expect: {
331         console.log(function() {
332             return "PASS";
333         }());
334     }
335     expect_stdout: "PASS"
336     node_version: ">=6"
337 }
338
339 funarg_unused_5: {
340     options = {
341         unused: true,
342     }
343     input: {
344         try {
345             (function({
346                 [c = 0]: c
347             }) {})(1);
348         } catch (e) {
349             console.log("PASS");
350         }
351     }
352     expect: {
353         try {
354             (function({
355                 [c = 0]: c
356             }) {})(1);
357         } catch (e) {
358             console.log("PASS");
359         }
360     }
361     expect_stdout: "PASS"
362     node_version: ">=6"
363 }
364
365 funarg_unused_6_inline: {
366     options = {
367         inline: true,
368         pure_getters: "strict",
369         unused: true,
370     }
371     input: {
372         (function(a) {
373             var {} = (a = console, 42);
374         })();
375         console.log(typeof a);
376     }
377     expect: {
378         void console;
379         console.log(typeof a);
380     }
381     expect_stdout: "undefined"
382     node_version: ">=6"
383 }
384
385 funarg_unused_6_keep_fargs: {
386     options = {
387         keep_fargs: false,
388         unused: true,
389     }
390     input: {
391         (function(a) {
392             var {} = (a = console, 42);
393         })();
394         console.log(typeof a);
395     }
396     expect: {
397         (function() {
398             var {} = (console, 42);
399         })();
400         console.log(typeof a);
401     }
402     expect_stdout: "undefined"
403     node_version: ">=6"
404 }
405
406 funarg_collapse_vars_1: {
407     options = {
408         collapse_vars: true,
409         unused: true,
410     }
411     input: {
412         console.log(function(a, {}) {
413             return typeof a;
414             var b;
415         }(console, {}));
416     }
417     expect: {
418         console.log(function(a, {}) {
419             return typeof (0, console);
420         }(0, {}));
421     }
422     expect_stdout: "object"
423     node_version: ">=6"
424 }
425
426 funarg_collapse_vars_2: {
427     options = {
428         collapse_vars: true,
429         keep_fargs: false,
430         unused: true,
431     }
432     input: {
433         console.log(function([ a ], { b }, c) {
434             return a + b + c;
435         }([ "P" ], { b: "A" }, "SS"));
436     }
437     expect: {
438         console.log(function([ a ], { b }) {
439             return a + b + "SS";
440         }([ "P" ], { b: "A" }));
441     }
442     expect_stdout: "PASS"
443     node_version: ">=6"
444 }
445
446 funarg_collapse_vars_3: {
447     options = {
448         collapse_vars: true,
449     }
450     input: {
451         var a = "FAIL";
452         try {
453             a = "PASS";
454             (function({}) {})();
455             throw "PASS";
456         } catch (e) {
457             console.log(a);
458         }
459     }
460     expect: {
461         var a = "FAIL";
462         try {
463             a = "PASS";
464             (function({}) {})();
465             throw "PASS";
466         } catch (e) {
467             console.log(a);
468         }
469     }
470     expect_stdout: "PASS"
471     node_version: ">=6"
472 }
473
474 funarg_reduce_vars_1: {
475     options = {
476         reduce_vars: true,
477         unused: true,
478     }
479     input: {
480         try {
481             (function({
482                 [a]: b,
483             }, a) {
484                 console.log("FAIL");
485             })({});
486         } catch (e) {
487             console.log("PASS");
488         }
489     }
490     expect: {
491         try {
492             (function({
493                 [a]: b,
494             }, a) {
495                 console.log("FAIL");
496             })({});
497         } catch (e) {
498             console.log("PASS");
499         }
500     }
501     expect_stdout: "PASS"
502     node_version: ">=6"
503 }
504
505 funarg_reduce_vars_2: {
506     options = {
507         evaluate: true,
508         keep_fargs: false,
509         pure_getters: "strict",
510         reduce_vars: true,
511         unsafe: true,
512         unused: true,
513     }
514     input: {
515         console.log(function([ a ], { b }, c) {
516             return a + b + c;
517         }([ "P" ], { b: "A" }, "SS"));
518     }
519     expect: {
520         console.log("PASS");
521     }
522     expect_stdout: "PASS"
523     node_version: ">=6"
524 }
525
526 funarg_reduce_vars_3: {
527     options = {
528         evaluate: true,
529         reduce_vars: true,
530         toplevel: true,
531     }
532     input: {
533         var a = 0;
534         (function({
535             [a++]: b
536         }) {})(0);
537         console.log(a);
538     }
539     expect: {
540         var a = 0;
541         (function({
542             [a++]: b
543         }) {})(0);
544         console.log(a);
545     }
546     expect_stdout: "1"
547     node_version: ">=6"
548 }
549
550 funarg_reduce_vars_4: {
551     options = {
552         evaluate: true,
553         reduce_vars: true,
554     }
555     input: {
556         try {
557             (function f({
558                 [a = 1]: a,
559             }) {})(2);
560         } catch (e) {
561             console.log("PASS");
562         }
563     }
564     expect: {
565         try {
566             (function f({
567                 [a = 1]: a,
568             }) {})(2);
569         } catch (e) {
570             console.log("PASS");
571         }
572     }
573     expect_stdout: "PASS"
574     node_version: ">=6"
575 }
576
577 funarg_computed_key_scope_1: {
578     rename = true
579     input: {
580         var b = 0;
581         function f({
582             [b]: a
583         }) {
584             var b = 42;
585             console.log(a, b);
586         }
587         f([ "PASS" ]);
588     }
589     expect: {
590         var b = 0;
591         function f({
592             [b]: a
593         }) {
594             var c = 42;
595             console.log(a, c);
596         }
597         f([ "PASS" ]);
598     }
599     expect_stdout: "PASS 42"
600     node_version: ">=6"
601 }
602
603 funarg_computed_key_scope_2: {
604     options = {
605         reduce_funcs: true,
606         reduce_vars: true,
607         unused: true,
608     }
609     input: {
610         (function({
611             [function() {
612                 console.log(typeof f);
613             }()]: a
614         }) {
615             function f() {}
616         })(0);
617     }
618     expect: {
619         (function({
620             [function() {
621                 console.log(typeof f);
622             }()]: a
623         }) {})(0);
624     }
625     expect_stdout: "undefined"
626     node_version: ">=6"
627 }
628
629 funarg_computed_key_scope_3: {
630     options = {
631         reduce_funcs: true,
632         reduce_vars: true,
633         unused: true,
634     }
635     input: {
636         (function({
637             [function() {
638                 (function({
639                     [function() {
640                         console.log(typeof f, typeof g, typeof h);
641                     }()]: a
642                 }) {
643                     function f() {}
644                 })(1);
645                 function g() {}
646             }()]: b
647         }) {
648             function h() {}
649         })(2);
650     }
651     expect: {
652         (function({
653             [function() {
654                 (function({
655                     [function() {
656                         console.log(typeof f, typeof function() {}, typeof h);
657                     }()]: a
658                 }) {})(1);
659             }()]: b
660         }) {})(2);
661     }
662     expect_stdout: "undefined function undefined"
663     node_version: ">=6"
664 }
665
666 funarg_inline: {
667     options = {
668         inline: true,
669         reduce_vars: true,
670         toplevel: true,
671         unused: true,
672     }
673     input: {
674         try {
675             function f({}) {
676                 return 42;
677             }
678             var a = f();
679         } catch (e) {
680             console.log("PASS");
681         }
682     }
683     expect: {
684         try {
685             [ {} ] = [];
686         } catch (e) {
687             console.log("PASS");
688         }
689     }
690     expect_stdout: "PASS"
691     node_version: ">=6"
692 }
693
694 process_boolean_returns: {
695     options = {
696         booleans: true,
697     }
698     input: {
699         console.log(function({ length }) {
700             return length ? "FAIL" : "PASS";
701         }(function() {
702             return 42;
703         }));
704     }
705     expect: {
706         console.log(function({ length }) {
707             return length ? "FAIL" : "PASS";
708         }(function() {
709             return 42;
710         }));
711     }
712     expect_stdout: "PASS"
713     node_version: ">=6"
714 }
715
716 simple_const: {
717     options = {
718         evaluate: true,
719         reduce_vars: true,
720         toplevel: true,
721         unsafe: true,
722         unused: true,
723         varify: true,
724     }
725     input: {
726         const [ a ] = [ "PASS" ];
727         console.log(a);
728     }
729     expect: {
730         console.log("PASS");
731     }
732     expect_stdout: "PASS"
733     node_version: ">=6"
734 }
735
736 simple_let: {
737     options = {
738         evaluate: true,
739         reduce_vars: true,
740         toplevel: true,
741         unsafe: true,
742         unused: true,
743         varify: true,
744     }
745     input: {
746         let [ a ] = [ "PASS" ];
747         console.log(a);
748     }
749     expect: {
750         console.log("PASS");
751     }
752     expect_stdout: "PASS"
753     node_version: ">=6"
754 }
755
756 simple_var: {
757     options = {
758         evaluate: true,
759         reduce_vars: true,
760         toplevel: true,
761         unsafe: true,
762         unused: true,
763     }
764     input: {
765         var [ a ] = [ "PASS" ];
766         console.log(a);
767     }
768     expect: {
769         console.log("PASS");
770     }
771     expect_stdout: "PASS"
772     node_version: ">=6"
773 }
774
775 drop_catch: {
776     options = {
777         dead_code: true,
778     }
779     input: {
780         try {} catch ({
781             [console.log("FAIL")]: e,
782         }) {} finally {
783             console.log("PASS");
784         }
785     }
786     expect: {
787         console.log("PASS");
788     }
789     expect_stdout: "PASS"
790     node_version: ">=6"
791 }
792
793 drop_catch_var: {
794     options = {
795         unused: true,
796     }
797     input: {
798         try {
799             throw new Error("PASS");
800         } catch ({ name, message }) {
801             console.log(message);
802         }
803     }
804     expect: {
805         try {
806             throw new Error("PASS");
807         } catch ({ message }) {
808             console.log(message);
809         }
810     }
811     expect_stdout: "PASS"
812     node_version: ">=6"
813 }
814
815 collapse_vars_1: {
816     options = {
817         collapse_vars: true,
818     }
819     input: {
820         var a = "PASS";
821         var {
822             [a.p]: a,
823         } = !console.log(a);
824     }
825     expect: {
826         var a = "PASS";
827         var {
828             [a.p]: a,
829         } = !console.log(a);
830     }
831     expect_stdout: "PASS"
832     node_version: ">=6"
833 }
834
835 collapse_vars_2: {
836     options = {
837         collapse_vars: true,
838     }
839     input: {
840         console.log(function() {
841             [] = [];
842             return "PASS";
843         }());
844     }
845     expect: {
846         console.log(function() {
847             [] = [];
848             return "PASS";
849         }());
850     }
851     expect_stdout: "PASS"
852     node_version: ">=6"
853 }
854
855 collapse_vars_3: {
856     options = {
857         collapse_vars: true,
858     }
859     input: {
860         console.log(function(a) {
861             [ a ] = (a = "FAIL", [ "PASS" ]);
862             return a;
863         }());
864     }
865     expect: {
866         console.log(function(a) {
867             [ a ] = (a = "FAIL", [ "PASS" ]);
868             return a;
869         }());
870     }
871     expect_stdout: "PASS"
872     node_version: ">=6"
873 }
874
875 collapse_vars_4: {
876     options = {
877         collapse_vars: true,
878     }
879     input: {
880         var a;
881         try {
882             a = 42;
883             [ 42..p ] = null;
884         } catch (e) {
885             console.log(a);
886         }
887     }
888     expect: {
889         var a;
890         try {
891             a = 42;
892             [ 42..p ] = null;
893         } catch (e) {
894             console.log(a);
895         }
896     }
897     expect_stdout: "42"
898     node_version: ">=6"
899 }
900
901 collapse_vars_5: {
902     options = {
903         collapse_vars: true,
904     }
905     input: {
906         var a;
907         try {
908             [] = (a = 42, null);
909             a = 42;
910         } catch (e) {
911             console.log(a);
912         }
913     }
914     expect: {
915         var a;
916         try {
917             [] = (a = 42, null);
918             a = 42;
919         } catch (e) {
920             console.log(a);
921         }
922     }
923     expect_stdout: "42"
924     node_version: ">=6"
925 }
926
927 collapse_vars_6: {
928     options = {
929         collapse_vars: true,
930     }
931     input: {
932         var a;
933         try {
934             var [] = (a = 42, null);
935             a = 42;
936         } catch (e) {
937             console.log(a);
938         }
939     }
940     expect: {
941         var a;
942         try {
943             var [] = (a = 42, null);
944             a = 42;
945         } catch (e) {
946             console.log(a);
947         }
948     }
949     expect_stdout: "42"
950     node_version: ">=6"
951 }
952
953 collapse_vars_7: {
954     options = {
955         collapse_vars: true,
956     }
957     input: {
958         var a = "FAIL";
959         try {
960             (function() {
961                 [] = (a = "PASS", null);
962                 return "PASS";
963             })();
964         } catch (e) {
965             console.log(a);
966         }
967     }
968     expect: {
969         var a = "FAIL";
970         try {
971             (function() {
972                 [] = (a = "PASS", null);
973                 return "PASS";
974             })();
975         } catch (e) {
976             console.log(a);
977         }
978     }
979     expect_stdout: "PASS"
980     node_version: ">=6"
981 }
982
983 collapse_vars_8: {
984     options = {
985         collapse_vars: true,
986     }
987     input: {
988         var a = "FAIL";
989         try {
990             (function() {
991                 var {} = (a = "PASS", null);
992                 return "PASS";
993             })();
994         } catch (e) {
995             console.log(a);
996         }
997     }
998     expect: {
999         var a = "FAIL";
1000         try {
1001             (function() {
1002                 var {} = (a = "PASS", null);
1003                 return "PASS";
1004             })();
1005         } catch (e) {
1006             console.log(a);
1007         }
1008     }
1009     expect_stdout: "PASS"
1010     node_version: ">=6"
1011 }
1012
1013 collapse_vars_9: {
1014     options = {
1015         collapse_vars: true,
1016     }
1017     input: {
1018         console.log(function(a) {
1019             try {
1020                 var b = function([ c ]) {
1021                     if (c)
1022                         return "FAIL 1";
1023                 }();
1024                 a = "FAIL 2";
1025                 return b;
1026             } catch (e) {
1027                 return a;
1028             }
1029         }("PASS"));
1030     }
1031     expect: {
1032         console.log(function(a) {
1033             try {
1034                 var b = function([ c ]) {
1035                     if (c)
1036                         return "FAIL 1";
1037                 }();
1038                 a = "FAIL 2";
1039                 return b;
1040             } catch (e) {
1041                 return a;
1042             }
1043         }("PASS"));
1044     }
1045     expect_stdout: "PASS"
1046     node_version: ">=6"
1047 }
1048
1049 conditionals: {
1050     options = {
1051         conditionals: true,
1052     }
1053     input: {
1054         if (console.log("PASS")) {
1055             var [] = 0;
1056         }
1057     }
1058     expect: {
1059         console.log("PASS") && ([] = 0);
1060     }
1061     expect_stdout: "PASS"
1062     node_version: ">=6"
1063 }
1064
1065 dead_code: {
1066     options = {
1067         conditionals: true,
1068         dead_code: true,
1069         evaluate: true,
1070     }
1071     input: {
1072         if (0) {
1073             let [] = 42;
1074             var { a, b: [ c ] } = null;
1075         }
1076         console.log("PASS");
1077     }
1078     expect: {
1079         0;
1080         var a, c;
1081         console.log("PASS");
1082     }
1083     expect_stdout: "PASS"
1084     node_version: ">=6"
1085 }
1086
1087 drop_unused_1: {
1088     options = {
1089         toplevel: true,
1090         unused: true,
1091     }
1092     input: {
1093         switch (0) {
1094           case console.log(a, a):
1095             try {
1096                 throw 42;
1097             } catch (a) {
1098                 var [ a ] = [];
1099             }
1100         }
1101     }
1102     expect: {
1103         switch (0) {
1104           case console.log(a, a):
1105             try {
1106                 throw 42;
1107             } catch (a) {
1108                 var a = [][0];
1109             }
1110         }
1111     }
1112     expect_stdout: "undefined undefined"
1113     node_version: ">=6"
1114 }
1115
1116 drop_unused_2: {
1117     options = {
1118         merge_vars: true,
1119         pure_getters: "strict",
1120         reduce_vars: true,
1121         toplevel: true,
1122         unused: true,
1123     }
1124     input: {
1125         function f(a) {
1126             var b = [ console.log("PASS"), a ], {
1127                 p: a,
1128             } = 0;
1129         }
1130         f();
1131     }
1132     expect:{
1133         (function(a) {
1134             console.log("PASS");
1135         })();
1136     }
1137     expect_stdout: "PASS"
1138     node_version: ">=6"
1139 }
1140
1141 drop_hole: {
1142     options = {
1143         unused: true,
1144     }
1145     input: {
1146         var [ a ] = [ , ];
1147         console.log(a);
1148     }
1149     expect: {
1150         var a = [][0];
1151         console.log(a);
1152     }
1153     expect_stdout: "undefined"
1154     node_version: ">=6"
1155 }
1156
1157 keep_key_1: {
1158     options = {
1159         evaluate: true,
1160         side_effects: true,
1161         unused: true,
1162     }
1163     input: {
1164         ({} = {
1165             [(console.log("PASS"), 42)]: null,
1166         });
1167     }
1168     expect: {
1169         ({} = {
1170             [(console.log("PASS"), 42)]: 0,
1171         });
1172     }
1173     expect_stdout: "PASS"
1174     node_version: ">=6"
1175 }
1176
1177 keep_key_2: {
1178     options = {
1179         evaluate: true,
1180         toplevel: true,
1181         unused: true,
1182     }
1183     input: {
1184         var { 42: a } = { [(console.log("PASS"), 42)](){} };
1185     }
1186     expect: {
1187         var {} = { [(console.log("PASS"), 42)]: 0 };
1188     }
1189     expect_stdout: "PASS"
1190     node_version: ">=6"
1191 }
1192
1193 keep_key_2_pure_getters: {
1194     options = {
1195         evaluate: true,
1196         pure_getters: "strict",
1197         toplevel: true,
1198         unused: true,
1199     }
1200     input: {
1201         var { 42: a } = { [(console.log("PASS"), 42)](){} };
1202     }
1203     expect: {
1204         console.log("PASS");
1205     }
1206     expect_stdout: "PASS"
1207     node_version: ">=6"
1208 }
1209
1210 keep_reference: {
1211     options = {
1212         reduce_vars: true,
1213         toplevel: true,
1214         unused: true,
1215     }
1216     input: {
1217         var a = [ {}, 42 ];
1218         var [ b, c ] = a;
1219         console.log(a[0] === b ? "PASS" : "FAIL");
1220     }
1221     expect: {
1222         var a = [ {}, 42 ];
1223         var [ b ] = a;
1224         console.log(a[0] === b ? "PASS" : "FAIL");
1225     }
1226     expect_stdout: "PASS"
1227     node_version: ">=6"
1228 }
1229
1230 maintain_position_assign: {
1231     options = {
1232         unused: true,
1233     }
1234     input: {
1235         console.log(([ , ] = [ , "PASS" ])[1]);
1236     }
1237     expect: {
1238         console.log([ , "PASS" ][1]);
1239     }
1240     expect_stdout: "PASS"
1241     node_version: ">=6"
1242 }
1243
1244 maintain_position_var: {
1245     options = {
1246         toplevel: true,
1247         unused: true,
1248     }
1249     input: {
1250         A = "FAIL";
1251         var [ a, b ] = [ A ];
1252         console.log(b || "PASS");
1253     }
1254     expect: {
1255         A = "FAIL";
1256         var [ , b ] = [ A ];
1257         console.log(b || "PASS");
1258     }
1259     expect_stdout: "PASS"
1260     node_version: ">=6"
1261 }
1262
1263 side_effects_array: {
1264     options = {
1265         unused: true,
1266     }
1267     input: {
1268         try {
1269             var [ a ] = 42;
1270         } catch (e) {
1271             console.log("PASS");
1272         }
1273     }
1274     expect: {
1275         try {
1276             var [ a ] = 42;
1277         } catch (e) {
1278             console.log("PASS");
1279         }
1280     }
1281     expect_stdout: "PASS"
1282     node_version: ">=6"
1283 }
1284
1285 side_effects_object: {
1286     options = {
1287         toplevel: true,
1288         unused: true,
1289     }
1290     input: {
1291         var a = null, b = console, { c } = 42;
1292         try {
1293             c[a = "PASS"];
1294         } catch (e) {
1295             console.log(a);
1296         }
1297     }
1298     expect: {
1299         var a = null, c = (console, 42["c"]);
1300         try {
1301             c[a = "PASS"];
1302         } catch (e) {
1303             console.log(a);
1304         }
1305     }
1306     expect_stdout: "PASS"
1307     node_version: ">=6"
1308 }
1309
1310 join_vars: {
1311     options = {
1312         conditionals: true,
1313         join_vars: true,
1314     }
1315     input: {
1316         const [ a ] = [ "PASS" ];
1317         a,
1318         console.log(a);
1319     }
1320     expect: {
1321         const [ a ] = [ "PASS" ];
1322         a,
1323         console.log(a);
1324     }
1325     expect_stdout: "PASS"
1326     node_version: ">=6"
1327 }
1328
1329 keep_fargs: {
1330     options = {
1331         keep_fargs: false,
1332         unused: true,
1333     }
1334     input: {
1335         console.log(function f(a) {
1336             var {} = a;
1337         }(0));
1338     }
1339     expect: {
1340         console.log(function(a) {
1341             var {} = a;
1342         }(0));
1343     }
1344     expect_stdout: "undefined"
1345     node_version: ">=6"
1346 }
1347
1348 reduce_vars_1: {
1349     options = {
1350         reduce_vars: true,
1351         toplevel: true,
1352         unused: true,
1353     }
1354     input: {
1355         var a;
1356         console.log("PASS") && ([ a ] = 0);
1357     }
1358     expect: {
1359         var a;
1360         console.log("PASS") && ([ a ] = 0);
1361     }
1362     expect_stdout: "PASS"
1363     node_version: ">=6"
1364 }
1365
1366 reduce_vars_2: {
1367     options = {
1368         evaluate: true,
1369         reduce_vars: true,
1370         toplevel: true,
1371         unused: true,
1372     }
1373     input: {
1374         var a = "FAIL", b = 42;
1375         ({
1376             [console.log(a, b)]: b.p
1377         } = a = "PASS");
1378     }
1379     expect: {
1380         ({
1381             [console.log("PASS", 42)]: 42..p
1382         } = "PASS");
1383     }
1384     expect_stdout: "PASS 42"
1385     node_version: ">=6"
1386 }
1387
1388 computed_key_evaluate: {
1389     options = {
1390         evaluate: true,
1391         reduce_vars: true,
1392         toplevel: true,
1393     }
1394     input: {
1395         var a = 0, {
1396             [++a]: b,
1397         } = [ "FAIL 1", a ? "FAIL 2" : "PASS" ];
1398         console.log(b);
1399     }
1400     expect: {
1401         var a = 0, {
1402             [1]: b,
1403         } = [ "FAIL 1", 0 ? "FAIL 2" : "PASS" ];
1404         console.log(b);
1405     }
1406     expect_stdout: "PASS"
1407     node_version: ">=6"
1408 }
1409
1410 computed_key_unused: {
1411     options = {
1412         toplevel: true,
1413         unused: true,
1414     }
1415     input: {
1416         var {
1417             [console.log("bar")]: a,
1418             [console.log("baz")]: { b },
1419             [console.log("moo")]: [
1420                 c,
1421                 {
1422                     [console.log("moz")]: d,
1423                     e,
1424                 },
1425             ],
1426         } = {
1427             [console.log("foo")]: [ null, 42 ],
1428         };
1429     }
1430     expect: {
1431         var {
1432             [console.log("bar")]: a,
1433             [console.log("baz")]: {},
1434             [console.log("moo")]: [
1435                 ,
1436                 {
1437                     [console.log("moz")]: d,
1438                 },
1439             ],
1440         } = {
1441             [console.log("foo")]: [ null, 42 ],
1442         };
1443     }
1444     expect_stdout: [
1445         "foo",
1446         "bar",
1447         "baz",
1448         "moo",
1449         "moz",
1450     ]
1451     node_version: ">=6"
1452 }
1453
1454 for_in_1: {
1455     options = {
1456         loops: true,
1457         toplevel: true,
1458         unused: true,
1459     }
1460     input: {
1461         for (var { a } in console.log("PASS"));
1462     }
1463     expect: {
1464         for (var { a } in console.log("PASS"));
1465     }
1466     expect_stdout: "PASS"
1467     node_version: ">=6"
1468 }
1469
1470 for_in_2: {
1471     options = {
1472         join_vars: true,
1473     }
1474     input: {
1475         var a;
1476         for (var { b } in console.log("PASS"));
1477     }
1478     expect: {
1479         var a, b;
1480         for ({ b } in console.log("PASS"));
1481     }
1482     expect_stdout: "PASS"
1483     node_version: ">=6"
1484 }
1485
1486 for_in_3: {
1487     options = {
1488         merge_vars: true,
1489         reduce_vars: true,
1490     }
1491     input: {
1492         for (var { length: a } in [ 42 ])
1493             console.log(a);
1494     }
1495     expect: {
1496         for (var { length: a } in [ 42 ])
1497             console.log(a);
1498     }
1499     expect_stdout: "1"
1500     node_version: ">=6"
1501 }
1502
1503 fn_name_evaluate: {
1504     options = {
1505         evaluate: true,
1506         objects: true,
1507         reduce_vars: true,
1508         typeofs: true,
1509     }
1510     input: {
1511         console.log(function f({
1512             [typeof f]: a,
1513         }) {
1514             var f;
1515             return a;
1516         }({
1517             function: "PASS",
1518             undefined: "FAIL",
1519         }));
1520     }
1521     expect: {
1522         console.log(function f({
1523             function: a,
1524         }) {
1525             var f;
1526             return a;
1527         }({
1528             function: "PASS",
1529             undefined: "FAIL",
1530         }));
1531     }
1532     expect_stdout: "PASS"
1533     node_version: ">=6"
1534 }
1535
1536 fn_name_unused: {
1537     options = {
1538         unused: true,
1539     }
1540     input: {
1541         console.log(function f({
1542             [typeof f]: a,
1543         }) {
1544             var f;
1545             return a;
1546         }({
1547             function: "PASS",
1548             undefined: "FAIL",
1549         }));
1550     }
1551     expect: {
1552         console.log(function f({
1553             [typeof f]: a,
1554         }) {
1555             var f;
1556             return a;
1557         }({
1558             function: "PASS",
1559             undefined: "FAIL",
1560         }));
1561     }
1562     expect_stdout: "PASS"
1563     node_version: ">=6"
1564 }
1565
1566 hoist_vars: {
1567     options = {
1568         hoist_vars: true,
1569     }
1570     input: {
1571         var a = "PASS";
1572         var [ b ] = [ 42 ];
1573         console.log(a, b);
1574     }
1575     expect: {
1576         var a = "PASS";
1577         var [ b ] = [ 42 ];
1578         console.log(a, b);
1579     }
1580     expect_stdout: "PASS 42"
1581     node_version: ">=6"
1582 }
1583
1584 singleton_1: {
1585     options = {
1586         pure_getters: true,
1587         side_effects: true,
1588         unused: true,
1589     }
1590     input: {
1591         var [ a ] = "P", b, o = {};
1592         [ { 1: o.p } ] = [ "FAIL" ];
1593         ({ foo: [ o.q ] } = { foo: "S" });
1594         [ b = "S" ] = [];
1595         console.log(a + o.p + o.q + b);
1596     }
1597     expect: {
1598         var b, a = "P"[0], o = {};
1599         o.p = [ "FAIL"["1"] ][0];
1600         o.q = { foo: "S"[0] }["foo"];
1601         [ b = "S" ] = [];
1602         console.log(a + o.p + o.q + b);
1603     }
1604     expect_stdout: "PASS"
1605     node_version: ">=6"
1606 }
1607
1608 singleton_2: {
1609     options = {
1610         evaluate: true,
1611         passes: 2,
1612         pure_getters: true,
1613         side_effects: true,
1614         unsafe: true,
1615         unused: true,
1616     }
1617     input: {
1618         var [ a ] = "P", b, o = {};
1619         [ { 1: o.p } ] = [ "FAIL" ];
1620         ({ foo: [ o.q ] } = { foo: "S" });
1621         [ b = "S" ] = [];
1622         console.log(a + o.p + o.q + b);
1623     }
1624     expect: {
1625         var b, a = "P", o = {};
1626         o.p = "A";
1627         o.q = "S";
1628         [ b = "S" ] = [];
1629         console.log(a + o.p + o.q + b);
1630     }
1631     expect_stdout: "PASS"
1632     node_version: ">=6"
1633 }
1634
1635 singleton_side_effects: {
1636     options = {
1637         side_effects: true,
1638         unused: true,
1639     }
1640     input: {
1641         [ 42[console.log("foo")] ] = [ console.log("bar") ];
1642     }
1643     expect: {
1644         [ 42[console.log("foo")] ] = [ console.log("bar") ];
1645     }
1646     expect_stdout: [
1647         "bar",
1648         "foo",
1649     ]
1650     node_version: ">=6"
1651 }
1652
1653 issue_4280: {
1654     options = {
1655         evaluate: true,
1656         reduce_vars: true,
1657         toplevel: true,
1658         unsafe: true,
1659         unused: true,
1660     }
1661     input: {
1662         var {
1663             1: a,
1664         } = 2;
1665         console.log(a);
1666     }
1667     expect: {
1668         var {} = 2;
1669         console.log(void 0);
1670     }
1671     expect_stdout: "undefined"
1672     node_version: ">=6"
1673 }
1674
1675 issue_4282: {
1676     options = {
1677         evaluate: true,
1678         reduce_vars: true,
1679         unused: true,
1680     }
1681     input: {
1682         (function(a) {
1683             ({
1684                 [a = "bar"]: 0[console.log(a)],
1685             } = 0);
1686         })("foo");
1687     }
1688     expect: {
1689         (function(a) {
1690             ({
1691                 [a = "bar"]: 0[console.log(a)],
1692             } = 0);
1693         })("foo");
1694     }
1695     expect_stdout: true
1696     node_version: ">=6"
1697 }
1698
1699 issue_4284_1: {
1700     options = {
1701         dead_code: true,
1702     }
1703     input: {
1704         var a, {
1705             0: b,
1706         } = a = "foo";
1707         console.log(a, b);
1708     }
1709     expect: {
1710         var a, {
1711             0: b,
1712         } = a = "foo";
1713         console.log(a, b);
1714     }
1715     expect_stdout: "foo f"
1716     node_version: ">=6"
1717 }
1718
1719 issue_4284_2: {
1720     options = {
1721         collapse_vars: true,
1722     }
1723     input: {
1724         var a, {
1725             [console.log(a)]: b,
1726         } = (a = "PASS", 0);
1727         var c = a;
1728     }
1729     expect: {
1730         var a, {
1731             [console.log(a)]: b,
1732         } = (a = "PASS", 0);
1733         var c = a;
1734     }
1735     expect_stdout: "PASS"
1736     node_version: ">=6"
1737 }
1738
1739 issue_4284_3: {
1740     options = {
1741         collapse_vars: true,
1742     }
1743     input: {
1744         var a, b;
1745         ({
1746             [console.log(a)]: b,
1747         } = (a = "PASS", 0));
1748         var c = a;
1749     }
1750     expect: {
1751         var a, b;
1752         ({
1753             [console.log(a)]: b,
1754         } = (a = "PASS", 0));
1755         var c = a;
1756     }
1757     expect_stdout: "PASS"
1758     node_version: ">=6"
1759 }
1760
1761 issue_4286_1: {
1762     options = {
1763         collapse_vars: true,
1764         toplevel: true,
1765     }
1766     input: {
1767         var a = "PASS", b;
1768         (0 && a)[{ a } = b = a];
1769         console.log(b);
1770     }
1771     expect: {
1772         var a = "PASS", b;
1773         (0 && a)[{ a } = b = a];
1774         console.log(b);
1775     }
1776     expect_stdout: "PASS"
1777     node_version: ">=6"
1778 }
1779
1780 issue_4286_2: {
1781     options = {
1782         collapse_vars: true,
1783         toplevel: true,
1784     }
1785     input: {
1786         a = [ "PASS" ];
1787         var b, { a } = b = a;
1788         console.log(b[0]);
1789     }
1790     expect: {
1791         var b, { a } = b = a = [ "PASS" ];
1792         console.log(b[0]);
1793     }
1794     expect_stdout: "PASS"
1795     node_version: ">=6"
1796 }
1797
1798 issue_4288: {
1799     options = {
1800         merge_vars: true,
1801     }
1802     input: {
1803         function f({
1804             [new function() {
1805                 console.log(typeof b);
1806             }()]: a,
1807         }) {
1808             var b = a;
1809             b++;
1810         }
1811         f(0);
1812     }
1813     expect: {
1814         function f({
1815             [new function() {
1816                 console.log(typeof b);
1817             }()]: a,
1818         }) {
1819             var b = a;
1820             b++;
1821         }
1822         f(0);
1823     }
1824     expect_stdout: "undefined"
1825     node_version: ">=6"
1826 }
1827
1828 issue_4294: {
1829     options = {
1830         merge_vars: true,
1831     }
1832     input: {
1833         A = "PASS";
1834         (function() {
1835             var a = function({
1836                 [a]: {},
1837             }) {}({
1838                 [a]: 0,
1839             });
1840             var b = A;
1841             console.log(b);
1842         })();
1843     }
1844     expect: {
1845         A = "PASS";
1846         (function() {
1847             var b = function({
1848                 [b]: {},
1849             }) {}({
1850                 [b]: 0,
1851             });
1852             var b = A;
1853             console.log(b);
1854         })();
1855     }
1856     expect_stdout: "PASS"
1857     node_version: ">=6"
1858 }
1859
1860 issue_4297: {
1861     options = {
1862         reduce_vars: true,
1863         unused: true,
1864     }
1865     input: {
1866         console.log(typeof function(a) {
1867             return { a } = a;
1868         }(function() {}));
1869     }
1870     expect: {
1871         console.log(typeof function(a) {
1872             return { a } = a;
1873         }(function() {}));
1874     }
1875     expect_stdout: "function"
1876     node_version: ">=6"
1877 }
1878
1879 issue_4298: {
1880     options = {
1881         merge_vars: true,
1882     }
1883     input: {
1884         (function() {
1885             var a = {
1886                 object: "PASS",
1887             };
1888             function f({
1889                 [typeof a]: b,
1890             }) {
1891                 var a = b;
1892                 return a;
1893             }
1894             var c = f(a);
1895             console.log(c);
1896         })();
1897     }
1898     expect: {
1899         (function() {
1900             var a = {
1901                 object: "PASS",
1902             };
1903             function f({
1904                 [typeof a]: b,
1905             }) {
1906                 var a = b;
1907                 return a;
1908             }
1909             var c = f(a);
1910             console.log(c);
1911         })();
1912     }
1913     expect_stdout: "PASS"
1914     node_version: ">=6"
1915 }
1916
1917 issue_4301: {
1918     options = {
1919         merge_vars: true,
1920     }
1921     input: {
1922         try {
1923             console.log(function() {
1924                 var a, b = console;
1925                 return {
1926                     [a = b]: a.p,
1927                 } = "foo";
1928             }());
1929         } catch (e) {
1930             console.log("bar");
1931         }
1932     }
1933     expect: {
1934         try {
1935             console.log(function() {
1936                 var a, b = console;
1937                 return {
1938                     [a = b]: a.p,
1939                 } = "foo";
1940             }());
1941         } catch (e) {
1942             console.log("bar");
1943         }
1944     }
1945     expect_stdout: true
1946     node_version: ">=6"
1947 }
1948
1949 issue_4308: {
1950     options = {
1951         collapse_vars: true,
1952         unused: true,
1953     }
1954     input: {
1955         var a = "PASS";
1956         console.log(function({
1957             [a = "FAIL"]: b
1958         }, c) {
1959             return c;
1960         }(0, a));
1961     }
1962     expect: {
1963         var a = "PASS";
1964         console.log(function({
1965             [a = "FAIL"]: b
1966         }, c) {
1967             return c;
1968         }(0, a));
1969     }
1970     expect_stdout: "PASS"
1971     node_version: ">=6"
1972 }
1973
1974 issue_4312: {
1975     options = {
1976         collapse_vars: true,
1977         inline: true,
1978         merge_vars: true,
1979         reduce_vars: true,
1980         toplevel: true,
1981         unused: true,
1982     }
1983     input: {
1984         var a;
1985         (function f(b, c) {
1986             return function({
1987                 [a = b]: d,
1988             }) {}(c && c);
1989         })("PASS", "FAIL");
1990         console.log(a);
1991     }
1992     expect: {
1993         var a;
1994         b = "PASS",
1995         c = "FAIL",
1996         [
1997             {
1998                 [a = b]: d,
1999             },
2000         ] = [ c && c ],
2001         void 0;
2002         var b, c, d;
2003         console.log(a);
2004     }
2005     expect_stdout: "PASS"
2006     node_version: ">=6"
2007 }
2008
2009 issue_4315: {
2010     options = {
2011         conditionals: true,
2012         dead_code: true,
2013         evaluate: true,
2014         inline: true,
2015         passes: 2,
2016         reduce_funcs: true,
2017         reduce_vars: true,
2018         side_effects: true,
2019         toplevel: true,
2020         unused: true,
2021     }
2022     input: {
2023         function f() {
2024             console;
2025         }
2026         var a = function() {
2027             if ([ 0[f && f] ] = [])
2028                 return this;
2029         }(), b;
2030         do {
2031             console.log("PASS");
2032         } while (0 && (b = 0), b && a);
2033     }
2034     expect: {
2035         [ 0[function() {
2036             console
2037         }] ] = [];
2038         do {
2039             console.log("PASS");
2040         } while (void 0);
2041     }
2042     expect_stdout: "PASS"
2043     node_version: ">=6"
2044 }
2045
2046 issue_4319: {
2047     options = {
2048         inline: true,
2049         reduce_vars: true,
2050         toplevel: true,
2051     }
2052     input: {
2053         function f(a) {
2054             while (!a);
2055         }
2056         console.log(function({}) {
2057             return f(console);
2058         }(0));
2059     }
2060     expect: {
2061         function f(a) {
2062             while (!a);
2063         }
2064         console.log(([ {} ] = [ 0 ], f(console)));
2065     }
2066     expect_stdout: "undefined"
2067     node_version: ">=6"
2068 }
2069
2070 issue_4321: {
2071     options = {
2072         inline: true,
2073         keep_fargs: false,
2074     }
2075     input: {
2076         try {
2077             console.log(function({}) {
2078                 return function() {
2079                     while (!console);
2080                 }();
2081             }());
2082         } catch (e) {
2083             console.log("PASS");
2084         }
2085     }
2086     expect: {
2087         try {
2088             console.log(([ {} ] = [], function() {
2089                 while (!console);
2090             }()));
2091         } catch (e) {
2092             console.log("PASS");
2093         }
2094     }
2095     expect_stdout: "PASS"
2096     node_version: ">=6"
2097 }
2098
2099 issue_4323: {
2100     options = {
2101         ie: true,
2102         inline: true,
2103         merge_vars: true,
2104         reduce_vars: true,
2105         toplevel: true,
2106         unused: true,
2107     }
2108     input: {
2109         var a = 0;
2110         (function b({
2111             [function a() {
2112                 console.log(typeof a);
2113             }()]: d,
2114         }) {})(0);
2115         (function c(e) {
2116             e.p;
2117         })(1, console.log);
2118     }
2119     expect: {
2120         var a = 0;
2121         [
2122             {
2123                 [function a() {
2124                     console.log(typeof a);
2125                 }()]: d,
2126             },
2127         ] = [ 0 ],
2128         void 0;
2129         var d;
2130         e = 1,
2131         console.log,
2132         void e.p;
2133         var e;
2134     }
2135     expect_stdout: "function"
2136     node_version: ">=6"
2137 }
2138
2139 issue_4355: {
2140     options = {
2141         loops: true,
2142         unused: true,
2143     }
2144     input: {
2145         var a;
2146         (function({
2147             [function() {
2148                 for (a in "foo");
2149             }()]: b,
2150         }) {
2151             var a;
2152         })(0);
2153         console.log(a);
2154     }
2155     expect: {
2156         var a;
2157         (function({
2158             [function() {
2159                 for (a in "foo");
2160             }()]: b,
2161         }) {})(0);
2162         console.log(a);
2163     }
2164     expect_stdout: "2"
2165     node_version: ">=6"
2166 }
2167
2168 issue_4372_1: {
2169     options = {
2170         dead_code: true,
2171     }
2172     input: {
2173         var a = "FAIL";
2174         a += {
2175             [console.log(a)]: a,
2176         } = a = "PASS";
2177     }
2178     expect: {
2179         var a = "FAIL";
2180         a += {
2181             [console.log(a)]: a,
2182         } = a = "PASS";
2183     }
2184     expect_stdout: "PASS"
2185     node_version: ">=6"
2186 }
2187
2188 issue_4372_2: {
2189     options = {
2190         dead_code: true,
2191     }
2192     input: {
2193         var a;
2194         [ a ] = a = [ "PASS", "FAIL" ];
2195         console.log(a);
2196     }
2197     expect: {
2198         var a;
2199         [ a ] = a = [ "PASS", "FAIL" ];
2200         console.log(a);
2201     }
2202     expect_stdout: "PASS"
2203     node_version: ">=6"
2204 }
2205
2206 issue_4383: {
2207     options = {
2208         evaluate: true,
2209         reduce_vars: true,
2210         unsafe: true,
2211     }
2212     input: {
2213         console.log(function(a) {
2214             [ a[0] ] = [];
2215             return a.length;
2216         }([]));
2217     }
2218     expect: {
2219         console.log(function(a) {
2220             [ a[0] ] = [];
2221             return a.length;
2222         }([]));
2223     }
2224     expect_stdout: "1"
2225     node_version: ">=6"
2226 }
2227
2228 issue_4386: {
2229     options = {
2230         arguments: true,
2231     }
2232     input: {
2233         function f({}) {
2234             return arguments[0];
2235         }
2236         console.log(f("PASS"));
2237     }
2238     expect: {
2239         function f({}) {
2240             return arguments[0];
2241         }
2242         console.log(f("PASS"));
2243     }
2244     expect_stdout: "PASS"
2245     node_version: ">=6"
2246 }
2247
2248 issue_4395: {
2249     options = {
2250         arguments: true,
2251     }
2252     input: {
2253         console.log(function(a, {}) {
2254             a = "FAIL";
2255             return arguments[0];
2256         }("PASS", 42));
2257     }
2258     expect: {
2259         console.log(function(a, {}) {
2260             a = "FAIL";
2261             return arguments[0];
2262         }("PASS", 42));
2263     }
2264     expect_stdout: "PASS"
2265     node_version: ">=6"
2266 }
2267
2268 issue_4399: {
2269     options = {
2270         arguments: true,
2271     }
2272     input: {
2273         console.log(function({
2274             [arguments[1]]: a,
2275         }, b) {
2276             return a;
2277         }([ "PASS" ], 0));
2278     }
2279     expect: {
2280         console.log(function({
2281             [arguments[1]]: a,
2282         }, b) {
2283             return a;
2284         }([ "PASS" ], 0));
2285     }
2286     expect_stdout: "PASS"
2287     node_version: ">=6"
2288 }
2289
2290 issue_4420: {
2291     options = {
2292         unused: true,
2293     }
2294     input: {
2295         console.log(function() {
2296             var a = 1;
2297             try {
2298                 throw [ "FAIL", "PASS" ];
2299             } catch ({
2300                 [a]: b,
2301             }) {
2302                 let a = 0;
2303                 return b;
2304             }
2305         }());
2306     }
2307     expect: {
2308         console.log(function() {
2309             var a = 1;
2310             try {
2311                 throw [ "FAIL", "PASS" ];
2312             } catch ({
2313                 [a]: b,
2314             }) {
2315                 return b;
2316             }
2317         }());
2318     }
2319     expect_stdout: "PASS"
2320     node_version: ">=8"
2321 }
2322
2323 issue_4425: {
2324     rename = true
2325     input: {
2326         var a;
2327         console.log(function() {
2328             try {
2329                 try {
2330                     throw 42;
2331                 } catch ({
2332                     [a]: a,
2333                 }) {}
2334                 return "FAIL";
2335             } catch (e) {
2336                 return "PASS";
2337             }
2338         }());
2339     }
2340     expect: {
2341         var a;
2342         console.log(function() {
2343             try {
2344                 try {
2345                     throw 42;
2346                 } catch ({
2347                     [b]: b,
2348                 }) {}
2349                 return "FAIL";
2350             } catch (c) {
2351                 return "PASS";
2352             }
2353         }());
2354     }
2355     expect_stdout: "PASS"
2356     node_version: ">=8"
2357 }
2358
2359 issue_4436_Infinity: {
2360     options = {
2361         unused: true,
2362     }
2363     input: {
2364         console.log(function({
2365             [delete Infinity]: a,
2366         }) {
2367             var Infinity;
2368             return a;
2369         }({
2370             true: "FAIL",
2371             false: "PASS",
2372         }));
2373     }
2374     expect: {
2375         console.log(function({
2376             [delete Infinity]: a,
2377         }) {
2378             return a;
2379         }({
2380             true: "FAIL",
2381             false: "PASS",
2382         }));
2383     }
2384     expect_stdout: true
2385     node_version: ">=6"
2386 }
2387
2388 issue_4436_NaN: {
2389     options = {
2390         unused: true,
2391     }
2392     input: {
2393         console.log(function({
2394             [delete NaN]: a,
2395         }) {
2396             var NaN;
2397             return a;
2398         }({
2399             true: "FAIL",
2400             false: "PASS",
2401         }));
2402     }
2403     expect: {
2404         console.log(function({
2405             [delete NaN]: a,
2406         }) {
2407             return a;
2408         }({
2409             true: "FAIL",
2410             false: "PASS",
2411         }));
2412     }
2413     expect_stdout: true
2414     node_version: ">=6"
2415 }
2416
2417 issue_4436_undefined: {
2418     options = {
2419         unused: true,
2420     }
2421     input: {
2422         console.log(function({
2423             [delete undefined]: a,
2424         }) {
2425             var undefined;
2426             return a;
2427         }({
2428             true: "FAIL",
2429             false: "PASS",
2430         }));
2431     }
2432     expect: {
2433         console.log(function({
2434             [delete undefined]: a,
2435         }) {
2436             return a;
2437         }({
2438             true: "FAIL",
2439             false: "PASS",
2440         }));
2441     }
2442     expect_stdout: true
2443     node_version: ">=6"
2444 }
2445
2446 issue_4446: {
2447     options = {
2448         collapse_vars: true,
2449     }
2450     input: {
2451         a = "PASS";
2452         var a = [ a[0] ] = [ a ];
2453         console.log(a[0]);
2454     }
2455     expect: {
2456         a = "PASS";
2457         var a = [ a[0] ] = [ a ];
2458         console.log(a[0]);
2459     }
2460     expect_stdout: "PASS"
2461     node_version: ">=6"
2462 }
2463
2464 issue_4456: {
2465     options = {
2466         pure_getters: "strict",
2467         unused: true,
2468     }
2469     input: {
2470         var o = {
2471             set p(v) {
2472                 console.log(v);
2473             },
2474         };
2475         [ function() {
2476             try {
2477                 return o;
2478             } catch ({}) {}
2479         }().p ] = [ "PASS" ];
2480     }
2481     expect: {
2482         var o = {
2483             set p(v) {
2484                 console.log(v);
2485             },
2486         };
2487         [ function() {
2488             try {
2489                 return o;
2490             } catch ({}) {}
2491         }().p ] = [ "PASS" ];
2492     }
2493     expect_stdout: "PASS"
2494     node_version: ">=6"
2495 }
2496
2497 issue_4485_1: {
2498     options = {
2499         pure_getters: "strict",
2500         side_effects: true,
2501     }
2502     input: {
2503         (function([]) {
2504             var arguments;
2505             try {
2506                 arguments.length;
2507             } catch (e) {
2508                 console.log("PASS");
2509             }
2510         })([]);
2511     }
2512     expect: {
2513         (function([]) {
2514             var arguments;
2515             try {
2516                 arguments.length;
2517             } catch (e) {
2518                 console.log("PASS");
2519             }
2520         })([]);
2521     }
2522     expect_stdout: true
2523     node_version: ">=6"
2524 }
2525
2526 issue_4485_2: {
2527     options = {
2528         pure_getters: "strict",
2529         side_effects: true,
2530     }
2531     input: {
2532         (function([]) {
2533             var arguments = null;
2534             try {
2535                 arguments.length;
2536             } catch (e) {
2537                 console.log("PASS");
2538             }
2539         })([]);
2540     }
2541     expect: {
2542         (function([]) {
2543             var arguments = null;
2544             try {
2545                 arguments.length;
2546             } catch (e) {
2547                 console.log("PASS");
2548             }
2549         })([]);
2550     }
2551     expect_stdout: "PASS"
2552     node_version: ">=6"
2553 }
2554
2555 issue_4485_3: {
2556     options = {
2557         keep_fargs: false,
2558         unused: true,
2559     }
2560     input: {
2561         (function([]) {
2562             var arguments;
2563             try {
2564                 arguments.length;
2565             } catch (e) {
2566                 console.log("PASS");
2567             }
2568         })([]);
2569     }
2570     expect: {
2571         (function([]) {
2572             var arguments;
2573             try {
2574                 arguments.length;
2575             } catch (e) {
2576                 console.log("PASS");
2577             }
2578         })([]);
2579     }
2580     expect_stdout: true
2581     node_version: ">=6"
2582 }
2583
2584 issue_4500: {
2585     options = {
2586         evaluate: true,
2587         keep_fnames: true,
2588         reduce_vars: true,
2589         toplevel: true,
2590         unused: true,
2591     }
2592     input: {
2593         var a = function f(b) {
2594             return [ b ] = [], b;
2595         }("FAIL");
2596         console.log(a || "PASS");
2597     }
2598     expect: {
2599         var a = function f(b) {
2600             return [ b ] = [], b;
2601         }("FAIL");
2602         console.log(a || "PASS");
2603     }
2604     expect_stdout: "PASS"
2605     node_version: ">=6"
2606 }
2607
2608 issue_4504: {
2609     options = {
2610         inline: true,
2611         merge_vars: true,
2612     }
2613     input: {
2614         A = "FAIL";
2615         (function f(a) {
2616             ({
2617                 [console.log(a)]: 0[(b => console + b)(A)]
2618             } = 0);
2619         })("PASS");
2620     }
2621     expect: {
2622         A = "FAIL";
2623         (function f(a) {
2624             ({
2625                 [console.log(a)]: 0[b = A, console + b]
2626             } = 0);
2627             var b;
2628         })("PASS");
2629     }
2630     expect_stdout: "PASS"
2631     node_version: ">=6"
2632 }
2633
2634 issue_4508: {
2635     options = {
2636         inline: true,
2637         toplevel: true,
2638         unused: true,
2639     }
2640     input: {
2641         for (var i = 0; i < 2; i++)
2642             (function f([ a ]) {
2643                 var a = console.log(a) && b, b = null;
2644             })([ "PASS" ]);
2645     }
2646     expect: {
2647         for (var i = 0; i < 2; i++)
2648             [ [ a ] ] = [ [ "PASS" ] ],
2649             b = void 0,
2650             a = console.log(a) && b,
2651             b = null,
2652             void 0;
2653         var a, b;
2654     }
2655     expect_stdout: [
2656         "PASS",
2657         "PASS",
2658     ]
2659     node_version: ">=6"
2660 }
2661
2662 issue_4512: {
2663     options = {
2664         side_effects: true,
2665     }
2666     input: {
2667         console.log(function([ a, b = a ]) {}([]));
2668     }
2669     expect: {
2670         console.log(function([ a, b = a ]) {}([]));
2671     }
2672     expect_stdout: "undefined"
2673     node_version: ">=6"
2674 }
2675
2676 issue_4519_1: {
2677     options = {
2678         arguments: true,
2679         keep_fargs: false,
2680     }
2681     input: {
2682         try {
2683             (function() {
2684                 var [ arguments ] = [];
2685                 arguments[0];
2686             })();
2687         } catch (e) {
2688             console.log("PASS");
2689         }
2690     }
2691     expect: {
2692         try {
2693             (function() {
2694                 var [ arguments ] = [];
2695                 arguments[0];
2696             })();
2697         } catch (e) {
2698             console.log("PASS");
2699         }
2700     }
2701     expect_stdout: "PASS"
2702     node_version: ">=6"
2703 }
2704
2705 issue_4519_2: {
2706     options = {
2707         pure_getters: "strict",
2708         side_effects: true,
2709     }
2710     input: {
2711         try {
2712             (function() {
2713                 var [ arguments ] = [];
2714                 arguments[0];
2715             })();
2716         } catch (e) {
2717             console.log("PASS");
2718         }
2719     }
2720     expect: {
2721         try {
2722             (function() {
2723                 var [ arguments ] = [];
2724                 arguments[0];
2725             })();
2726         } catch (e) {
2727             console.log("PASS");
2728         }
2729     }
2730     expect_stdout: "PASS"
2731     node_version: ">=6"
2732 }
2733
2734 issue_4554: {
2735     options = {
2736         collapse_vars: true,
2737         unused: true,
2738     }
2739     input: {
2740         A = "PASS";
2741         var a = "FAIL";
2742         try {
2743             (function({}, b) {
2744                 return b;
2745             })(void 0, a = A);
2746         } catch (e) {
2747             console.log(a);
2748         }
2749     }
2750     expect: {
2751         A = "PASS";
2752         var a = "FAIL";
2753         try {
2754             (function({}, b) {
2755                 return b;
2756             })(void 0, a = A);
2757         } catch (e) {
2758             console.log(a);
2759         }
2760     }
2761     expect_stdout: "PASS"
2762     node_version: ">=6"
2763 }
2764
2765 issue_4584: {
2766     options = {
2767         evaluate: true,
2768         reduce_vars: true,
2769     }
2770     input: {
2771         try {
2772             (function f({
2773                 [console.log(a = "FAIL")]: a,
2774             }) {})(0);
2775         } catch (e) {
2776             console.log("PASS");
2777         }
2778     }
2779     expect: {
2780         try {
2781             (function f({
2782                 [console.log(a = "FAIL")]: a,
2783             }) {})(0);
2784         } catch (e) {
2785             console.log("PASS");
2786         }
2787     }
2788     expect_stdout: "PASS"
2789     node_version: ">=6"
2790 }
2791
2792 issue_4608_1: {
2793     options = {
2794         arguments: true,
2795         keep_fargs: false,
2796     }
2797     input: {
2798         (function() {
2799             [ arguments ] = [ "foo" ];
2800             console.log(arguments[0]);
2801         })();
2802     }
2803     expect: {
2804         (function() {
2805             [ arguments ] = [ "foo" ];
2806             console.log(arguments[0]);
2807         })();
2808     }
2809     expect_stdout: "f"
2810     node_version: ">=6"
2811 }
2812
2813 issue_4608_2: {
2814     options = {
2815         arguments: true,
2816         reduce_vars: true,
2817     }
2818     input: {
2819         (function(a) {
2820             [ arguments ] = [ "foo" ];
2821             console.log(arguments[0]);
2822         })();
2823     }
2824     expect: {
2825         (function(a) {
2826             [ arguments ] = [ "foo" ];
2827             console.log(arguments[0]);
2828         })();
2829     }
2830     expect_stdout: "f"
2831     node_version: ">=6"
2832 }
2833
2834 issue_4994: {
2835     options = {
2836         loops: true,
2837         unused: true,
2838     }
2839     input: {
2840         var a = "FAIL";
2841         (function([
2842             {
2843                 [function() {
2844                     for (a in { PASS: null });
2845                 }()]: b,
2846             },
2847         ]) {
2848             var a;
2849         })([ 42 ]);
2850         console.log(a);
2851     }
2852     expect: {
2853         var a = "FAIL";
2854         (function([
2855             {
2856                 [function() {
2857                     for (a in { PASS: null });
2858                 }()]: b,
2859             },
2860         ]) {})([ 42 ]);
2861         console.log(a);
2862     }
2863     expect_stdout: "PASS"
2864     node_version: ">=6"
2865 }
2866
2867 issue_5017: {
2868     options = {
2869         collapse_vars: true,
2870         reduce_vars: true,
2871         toplevel: true,
2872     }
2873     input: {
2874         var a = function() {};
2875         var b = c = a;
2876         var c = [ c ] = [ c ];
2877         console.log(c[0] === a ? "PASS" : "FAIL");
2878     }
2879     expect: {
2880         var a = function() {};
2881         var b = a;
2882         var c = [ c ] = [ c = a ];
2883         console.log(c[0] === a ? "PASS" : "FAIL");
2884     }
2885     expect_stdout: "PASS"
2886     node_version: ">=6"
2887 }
2888
2889 issue_5071_1: {
2890     options = {
2891         unused: true,
2892     }
2893     input: {
2894         var a;
2895         console.log(([ , a ] = [ "PA", , ]).join("SS"));
2896     }
2897     expect: {
2898         var a;
2899         console.log(([ , a ] = [ "PA", , ]).join("SS"));
2900     }
2901     expect_stdout: "PASS"
2902     node_version: ">=6"
2903 }
2904
2905 issue_5071_2: {
2906     options = {
2907         pure_getters: "strict",
2908         unused: true,
2909     }
2910     input: {
2911         var a;
2912         ([ a ] = []).p = console.log("PASS");
2913     }
2914     expect: {
2915         var a;
2916         ([ a ] = []).p = console.log("PASS");
2917     }
2918     expect_stdout: "PASS"
2919     node_version: ">=6"
2920 }
2921
2922 issue_5074_getter: {
2923     options = {
2924         evaluate: true,
2925         side_effects: true,
2926         unused: true,
2927     }
2928     input: {
2929         ({} = { get [(console.log("PASS"), 42)]() {} });
2930     }
2931     expect: {
2932         ({} = { [(console.log("PASS"), 42)]: 0 });
2933     }
2934     expect_stdout: "PASS"
2935     node_version: ">=6"
2936 }
2937
2938 issue_5074_getter_pure_getters: {
2939     options = {
2940         evaluate: true,
2941         pure_getters: "strict",
2942         side_effects: true,
2943         unused: true,
2944     }
2945     input: {
2946         ({} = { get [(console.log("PASS"), 42)]() {} });
2947     }
2948     expect: {
2949         console.log("PASS");
2950     }
2951     expect_stdout: "PASS"
2952     node_version: ">=6"
2953 }
2954
2955 issue_5074_setter: {
2956     options = {
2957         evaluate: true,
2958         side_effects: true,
2959         unused: true,
2960     }
2961     input: {
2962         ({} = { set [(console.log("PASS"), 42)](v) {} });
2963     }
2964     expect: {
2965         ({} = { [(console.log("PASS"), 42)]: 0 });
2966     }
2967     expect_stdout: "PASS"
2968     node_version: ">=6"
2969 }
2970
2971 issue_5074_setter_pure_getters: {
2972     options = {
2973         evaluate: true,
2974         pure_getters: "strict",
2975         side_effects: true,
2976         unused: true,
2977     }
2978     input: {
2979         ({} = { set [(console.log("PASS"), 42)](v) {} });
2980     }
2981     expect: {
2982         console.log("PASS");
2983     }
2984     expect_stdout: "PASS"
2985     node_version: ">=6"
2986 }
2987
2988 issue_5074_method: {
2989     options = {
2990         evaluate: true,
2991         side_effects: true,
2992         unused: true,
2993     }
2994     input: {
2995         ({} = { [(console.log("PASS"), 42)]() {} });
2996     }
2997     expect: {
2998         ({} = { [(console.log("PASS"), 42)]: 0 });
2999     }
3000     expect_stdout: "PASS"
3001     node_version: ">=6"
3002 }
3003
3004 issue_5074_method_pure_getters: {
3005     options = {
3006         evaluate: true,
3007         pure_getters: "strict",
3008         side_effects: true,
3009         unused: true,
3010     }
3011     input: {
3012         ({} = { [(console.log("PASS"), 42)]() {} });
3013     }
3014     expect: {
3015         console.log("PASS");
3016     }
3017     expect_stdout: "PASS"
3018     node_version: ">=6"
3019 }
3020
3021 issue_5085_1: {
3022     options = {
3023         evaluate: true,
3024         reduce_vars: true,
3025         toplevel: true,
3026         unsafe: true,
3027         unused: true,
3028     }
3029     input: {
3030         var a = "PASS";
3031         var [ b ] = [ 42, a ], c = b ? 0 : a = "FAIL";
3032         console.log(a);
3033     }
3034     expect: {
3035         var a = "PASS";
3036         var b = [ 42 ][0];
3037         b;
3038         console.log(a);
3039     }
3040     expect_stdout: "PASS"
3041     node_version: ">=6"
3042 }
3043
3044 issue_5085_2: {
3045     options = {
3046         evaluate: true,
3047         reduce_vars: true,
3048         side_effects: true,
3049         unsafe: true,
3050         unused: true,
3051     }
3052     input: {
3053         var a = "PASS";
3054         (function(b) {
3055             [ b ] = [ 42, a ];
3056             var c = b ? 0 : a = "FAIL";
3057         })();
3058         console.log(a);
3059     }
3060     expect: {
3061         var a = "PASS";
3062         (function(b) {
3063             b = [ 42 ][0];
3064         })();
3065         console.log(a);
3066     }
3067     expect_stdout: "PASS"
3068     node_version: ">=6"
3069 }
3070
3071 issue_5087_1: {
3072     options = {
3073         collapse_vars: true,
3074         inline: true,
3075         properties: true,
3076         sequences: true,
3077         side_effects: true,
3078         unused: true,
3079     }
3080     input: {
3081         var a = "PASS";
3082         (function() {
3083             (function() {
3084                 (function([ b ]) {
3085                     b && console.log(b);
3086                 })([ a ]);
3087             })();
3088         })();
3089     }
3090     expect: {
3091         var a = "PASS";
3092         (function() {
3093             var b;
3094             (b = a) && console.log(b);
3095         })();
3096     }
3097     expect_stdout: "PASS"
3098     node_version: ">=6"
3099 }
3100
3101 issue_5087_2: {
3102     options = {
3103         collapse_vars: true,
3104         inline: true,
3105         passes: 2,
3106         properties: true,
3107         reduce_vars: true,
3108         sequences: true,
3109         side_effects: true,
3110         unused: true,
3111     }
3112     input: {
3113         var a = "PASS";
3114         (function() {
3115             (function() {
3116                 (function([ b ]) {
3117                     b && console.log(b);
3118                 })([ a ]);
3119             })();
3120         })();
3121     }
3122     expect: {
3123         var a = "PASS";
3124         a && console.log(a);
3125     }
3126     expect_stdout: "PASS"
3127     node_version: ">=6"
3128 }
3129
3130 issue_5114_1: {
3131     options = {
3132         inline: true,
3133         unused: true,
3134     }
3135     input: {
3136         var a = "PASS";
3137         (function({}, a) {})(42);
3138         console.log(a);
3139     }
3140     expect: {
3141         var a = "PASS";
3142         [ {} ] = [ 42 ],
3143         void 0;
3144         console.log(a);
3145     }
3146     expect_stdout: "PASS"
3147     node_version: ">=6"
3148 }
3149
3150 issue_5114_2: {
3151     options = {
3152         inline: true,
3153         pure_getters: "strict",
3154         reduce_vars: true,
3155         side_effects: true,
3156         unused: true,
3157     }
3158     input: {
3159         var a = "PASS";
3160         (function f([], a) {
3161             f.length;
3162         })([]);
3163         console.log(a);
3164     }
3165     expect: {
3166         var a = "PASS";
3167         0;
3168         console.log(a);
3169     }
3170     expect_stdout: "PASS"
3171     node_version: ">=6"
3172 }
3173
3174 issue_5114_3: {
3175     options = {
3176         inline: true,
3177         pure_getters: "strict",
3178         reduce_vars: true,
3179         side_effects: true,
3180         unused: true,
3181     }
3182     input: {
3183         var a = "PASS";
3184         (function f(a, {}) {
3185             f.length;
3186         })(null, 42);
3187         console.log(a);
3188     }
3189     expect: {
3190         var a = "PASS";
3191         0;
3192         console.log(a);
3193     }
3194     expect_stdout: "PASS"
3195     node_version: ">=6"
3196 }
3197
3198 issue_5153_array_assign: {
3199     options = {
3200         dead_code: true,
3201     }
3202     input: {
3203         var a = function*() {
3204             yield b;
3205         }(), b;
3206         [ b ] = b = a;
3207         console.log(a === b ? "PASS" : "FAIL");
3208     }
3209     expect: {
3210         var a = function*() {
3211             yield b;
3212         }(), b;
3213         [ b ] = b = a;
3214         console.log(a === b ? "PASS" : "FAIL");
3215     }
3216     expect_stdout: "PASS"
3217     node_version: ">=6"
3218 }
3219
3220 issue_5153_array_var: {
3221     options = {
3222         dead_code: true,
3223     }
3224     input: {
3225         var a = function*() {
3226             yield b;
3227         }(), [ b ] = b = a;
3228         console.log(a === b ? "PASS" : "FAIL");
3229     }
3230     expect: {
3231         var a = function*() {
3232             yield b;
3233         }(), [ b ] = b = a;
3234         console.log(a === b ? "PASS" : "FAIL");
3235     }
3236     expect_stdout: "PASS"
3237     node_version: ">=6"
3238 }
3239
3240 issue_5153_object_assign: {
3241     options = {
3242         dead_code: true,
3243     }
3244     input: {
3245         var a = {
3246             get p() {
3247                 return b;
3248             },
3249         }, b;
3250         ({
3251             p: b
3252         } = b = a);
3253         console.log(a === b ? "PASS" : "FAIL");
3254     }
3255     expect: {
3256         var a = {
3257             get p() {
3258                 return b;
3259             },
3260         }, b;
3261         ({
3262             p: b
3263         } = b = a);
3264         console.log(a === b ? "PASS" : "FAIL");
3265     }
3266     expect_stdout: "PASS"
3267     node_version: ">=6"
3268 }
3269
3270 issue_5153_object_var: {
3271     options = {
3272         dead_code: true,
3273     }
3274     input: {
3275         var a = {
3276             get p() {
3277                 return b;
3278             },
3279         }, {
3280             p: b
3281         } = b = a;
3282         console.log(a === b ? "PASS" : "FAIL");
3283     }
3284     expect: {
3285         var a = {
3286             get p() {
3287                 return b;
3288             },
3289         }, {
3290             p: b
3291         } = b = a;
3292         console.log(a === b ? "PASS" : "FAIL");
3293     }
3294     expect_stdout: "PASS"
3295     node_version: ">=6"
3296 }
3297
3298 issue_5168: {
3299     options = {
3300         collapse_vars: true,
3301     }
3302     input: {
3303         (function a({
3304             [console.log(typeof function() {
3305                 ++a;
3306                 return a;
3307             }())]: b,
3308         }) {
3309             var a;
3310         })({});
3311     }
3312     expect: {
3313         (function a({
3314             [console.log(typeof function() {
3315                 ++a;
3316                 return a;
3317             }())]: b,
3318         }) {
3319             var a;
3320         })({});
3321     }
3322     expect_stdout: "function"
3323     node_version: ">=6"
3324 }
3325
3326 issue_5189_1: {
3327     options = {
3328         pure_getters: "strict",
3329         reduce_vars: true,
3330         side_effects: true,
3331         toplevel: true,
3332         unused: true,
3333     }
3334     input: {
3335         var a = 42;
3336         [ a.p ] = a = "PASS";
3337         console.log(a);
3338     }
3339     expect: {
3340         var a;
3341         [ a.p ] = a = "PASS";
3342         console.log(a);
3343     }
3344     expect_stdout: "PASS"
3345     node_version: ">=6"
3346 }
3347
3348 issue_5189_2: {
3349     options = {
3350         pure_getters: "strict",
3351         reduce_vars: true,
3352         side_effects: true,
3353         toplevel: true,
3354         unused: true,
3355     }
3356     input: {
3357         var a = 42;
3358         ({ p: a.q } = a = "PASS");
3359         console.log(a);
3360     }
3361     expect: {
3362         var a;
3363         ({ p: a.q } = a = "PASS");
3364         console.log(a);
3365     }
3366     expect_stdout: "PASS"
3367     node_version: ">=6"
3368 }