-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.json
5772 lines (5772 loc) · 335 KB
/
data.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
{
"name": "Object/array literal extensions",
"target": "es5",
"significance": "large",
"subtests": [
{
"name": "Getter accessors",
"exec": "return ({ get x(){ return 1 } }).x === 1;"
},
{
"name": "Setter accessors",
"exec": "var value = 0;\n({ set x(v){ value = v; } }).x = 1;\nreturn value === 1;"
},
{
"name": "Trailing commas in object literals",
"exec": "return { a: true, }.a === true;"
},
{
"name": "Trailing commas in array literals",
"exec": "return [1,].length === 1;"
},
{
"name": "Reserved words as property names",
"exec": "return ({ if: 1 }).if === 1;"
}
]
},
{
"name": "Object static methods",
"target": "es5",
"significance": "large",
"subtests": [
{
"name": "Object.create",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create",
"exec": "function () {\nreturn typeof Object.create === 'function';\n }"
},
{
"name": "Object.defineProperty",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty",
"exec": "function () {\nreturn typeof Object.defineProperty === 'function';\n }"
},
{
"name": "Object.defineProperties",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties",
"exec": "function () {\nreturn typeof Object.defineProperties === 'function';\n }"
},
{
"name": "Object.getPrototypeOf",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf",
"exec": "function () {\nreturn typeof Object.getPrototypeOf === 'function';\n }"
},
{
"name": "Object.keys",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys",
"exec": "function () {\nreturn typeof Object.keys === 'function';\n }"
},
{
"name": "Object.seal",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal",
"exec": "function () {\nreturn typeof Object.seal === 'function';\n }"
},
{
"name": "Object.freeze",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze",
"exec": "function () {\nreturn typeof Object.freeze === 'function';\n }"
},
{
"name": "Object.preventExtensions",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions",
"exec": "function () {\nreturn typeof Object.preventExtensions === 'function';\n }"
},
{
"name": "Object.isSealed",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed",
"exec": "function () {\nreturn typeof Object.isSealed === 'function';\n }"
},
{
"name": "Object.isFrozen",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen",
"exec": "function () {\nreturn typeof Object.isFrozen === 'function';\n }"
},
{
"name": "Object.isExtensible",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible",
"exec": "function () {\nreturn typeof Object.isExtensible === 'function';\n }"
},
{
"name": "Object.getOwnPropertyDescriptor",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor",
"exec": "function () {\nreturn typeof Object.getOwnPropertyDescriptor === 'function';\n }"
},
{
"name": "Object.getOwnPropertyNames",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames",
"exec": "function () {\nreturn typeof Object.getOwnPropertyNames === 'function';\n }"
}
]
},
{
"name": "Array methods",
"target": "es5",
"significance": "large",
"subtests": [
{
"name": "Array.isArray",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray",
"exec": "function () {\nreturn typeof Array.isArray === 'function';\n }"
},
{
"name": "Array.prototype.indexOf",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf",
"exec": "function () {\nreturn typeof Array.prototype.indexOf === 'function';\n }"
},
{
"name": "Array.prototype.lastIndexOf",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf",
"exec": "function () {\nreturn typeof Array.prototype.lastIndexOf === 'function';\n }"
},
{
"name": "Array.prototype.every",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every",
"exec": "function () {\nreturn typeof Array.prototype.every === 'function';\n }"
},
{
"name": "Array.prototype.some",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some",
"exec": "function () {\nreturn typeof Array.prototype.some === 'function';\n }"
},
{
"name": "Array.prototype.forEach",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach",
"exec": "function () {\nreturn typeof Array.prototype.forEach === 'function';\n }"
},
{
"name": "Array.prototype.map",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map",
"exec": "function () {\nreturn typeof Array.prototype.map === 'function';\n }"
},
{
"name": "Array.prototype.filter",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter",
"exec": "function () {\nreturn typeof Array.prototype.filter === 'function';\n }"
},
{
"name": "Array.prototype.reduce",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce",
"exec": "function () {\nreturn typeof Array.prototype.reduce === 'function';\n }"
},
{
"name": "Array.prototype.reduceRight",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight",
"exec": "function () {\nreturn typeof Array.prototype.reduceRight === 'function';\n }"
},
{
"name": "Array.prototype.sort: compareFn must be function or undefined",
"exec": "function () {\ntry {\n [1,2].sort(null);\n return false;\n} catch (enull) {}\ntry {\n [1,2].sort(true);\n return false;\n} catch (etrue) {}\ntry {\n [1,2].sort({});\n return false;\n} catch (eobj) {}\ntry {\n [1,2].sort([]);\n return false;\n} catch (earr) {}\ntry {\n [1,2].sort(/a/g);\n return false;\n} catch (eregex) {}\nreturn true;\n }"
},
{
"name": "Array.prototype.sort: compareFn may be explicit undefined",
"exec": "function () {\ntry {\n var arr = [2, 1];\n return arr.sort(undefined) === arr && arr[0] === 1 && arr[1] === 2;\n} catch (e) {\n return false;\n}\n }"
},
{
"name": "Array.prototype.unshift: [].unshift(0) returns the unshifted count",
"exec": "function () {\nreturn [].unshift(0) === 1;\n }"
}
]
},
{
"name": "String properties and methods",
"target": "es5",
"significance": "small",
"subtests": [
{
"name": "Property access on strings",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#Character_access",
"exec": "function () {\nreturn \"foobar\"[3] === \"b\";\n }"
},
{
"name": "String.prototype.split",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split",
"exec": "function () {\n// all of these tests reflect bugs that es5-shim patches\nreturn typeof String.prototype.split === 'function'\n && ''.split().length === 1 && ''.split()[0] === ''\n && ''.split(undefined).length === 1 && ''.split(undefined)[0] === ''\n && 'ab'.split().length === 1 && 'ab'.split()[0] === 'ab'\n && 'ab'.split(undefined).length === 1 && 'ab'.split(undefined)[0] === 'ab'\n && '0'.split(undefined, 0).length === 0\n && 'ab'.split(/(?:ab)*/).length === 2\n && '.'.split(/(.?)(.?)/).length === 4\n && 'tesst'.split(/(s)*/)[1] !== 't'\n && 'test'.split(/(?:)/, -1).length === 4\n && ''.split(/.?/).length === 0\n && '.'.split(/()()/).length === 1;\n }"
},
{
"name": "String.prototype.substr",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr",
"exec": "function () {\nreturn '0b'.substr(-1) === 'b';\n }"
},
{
"name": "String.prototype.trim",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim",
"exec": "function () {\nreturn typeof String.prototype.trim === 'function';\n }"
}
]
},
{
"name": "Date methods",
"target": "es5",
"significance": "small",
"subtests": [
{
"name": "Date.prototype.toISOString",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString",
"exec": "function () {\nreturn typeof Date.prototype.toISOString === 'function';\n }"
},
{
"name": "Date.now",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now",
"exec": "function () {\nreturn typeof Date.now === 'function';\n }"
},
{
"name": "Date.prototype.toJSON",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON",
"exec": "function () {\ntry {\n return Date.prototype.toJSON.call(new Date(NaN)) === null;\n} catch (e) {\n return false;\n}\n }"
}
]
},
{
"name": "Function.prototype.bind",
"target": "es5",
"significance": "medium",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind",
"exec": "function () {\nreturn typeof Function.prototype.bind === 'function';\n }"
},
{
"name": "JSON",
"target": "es5",
"significance": "medium",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON",
"exec": "function () {\nreturn typeof JSON === 'object';\n }"
},
{
"name": "Immutable globals",
"target": "es5",
"significance": "small",
"subtests": [
{
"name": "undefined",
"exec": "undefined = 12345;\nvar result = typeof undefined === 'undefined';\nundefined = void 0;\nreturn result;"
},
{
"name": "NaN",
"exec": "NaN = false;\nvar result = typeof NaN === 'number';\nNaN = Math.sqrt(-1);\nreturn result;"
},
{
"name": "Infinity",
"exec": "Infinity = false;\nvar result = typeof Infinity === 'number';\nInfinity = 1/0;\nreturn result;"
}
]
},
{
"name": "Number methods",
"target": "es5",
"significance": "small",
"subtests": [
{
"name": "Number.prototype.toExponential rounds properly",
"exec": "function () {\nreturn (-6.9e-11).toExponential(4) === '-6.9000e-11' // Edge <= 17\n && (25).toExponential(0) === '3e+1' // FF <= 86\n && (1.255).toExponential(2) === '1.25e+0'; // IE <= 11 && Edge <= 14\n }"
},
{
"name": "Number.prototype.toExponential throws on ±Infinity fractionDigits",
"exec": "function () {\ntry {\n (1).toExponential(Infinity);\n (1).toExponential(-Infinity);\n return false;\n} catch (e) {\n return true;\n}\n }"
},
{
"name": "Number.prototype.toExponential does not throw on edge cases",
"exec": "function () {\ntry {\n NaN.toExponential(Infinity);\n Infinity.toExponential(Infinity);\n return true;\n} catch (e) {\n return false;\n}\n }"
}
]
},
{
"name": "Miscellaneous",
"target": "es5",
"significance": "medium",
"subtests": [
{
"name": "Function.prototype.apply permits array-likes",
"exec": "function () {\ntry {\n return (function(a,b) { return a === 1 && b === 2; }).apply({}, {0:1, 1:2, length:2});\n} catch (e) {\n return false;\n}\n }"
},
{
"name": "parseInt ignores leading zeros",
"exec": "function () {\nreturn parseInt('010') === 10;\n }"
},
{
"name": "Function \"prototype\" property is non-enumerable",
"exec": "return !Function().propertyIsEnumerable('prototype');"
},
{
"name": "Arguments toStringTag is \"Arguments\"",
"exec": "return (function(){ return Object.prototype.toString.call(arguments) === '[object Arguments]'; }());"
},
{
"name": "Zero-width chars in identifiers",
"exec": "var _\\u200c\\u200d = true;\nreturn _\\u200c\\u200d;"
},
{
"name": "Unreserved words",
"exec": "var abstract, boolean, byte, char, double, final, float, goto, int, long,\n native, short, synchronized, transient, volatile;\nreturn true;"
},
{
"name": "Enumerable properties can be shadowed by non-enumerables",
"exec": "var result = true;\nObject.prototype.length = 42;\nfor (var i in Function) {\n if (i === 'length') {\n result = false;\n }\n}\ndelete Object.prototype.length;\nreturn result;"
},
{
"name": "Thrown functions have proper \"this\" values",
"exec": "try {\n throw function() { return !('a' in this); };\n}\ncatch(e) {\n var a = true;\n return e();\n}"
}
]
},
{
"name": "Strict mode",
"target": "es5",
"significance": "large",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode",
"subtests": [
{
"name": "reserved words",
"exec": "'use strict';\nvar words = 'implements,interface,let,package,private,protected,public,static,yield'.split(',');\nfor (var i = 0; i < 9; i+=1) {\n try { eval('var ' + words[i]); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\n}\nreturn true;"
},
{
"name": "\"this\" is undefined in functions",
"exec": "'use strict';\nreturn this === void undefined && (function(){ return this === void undefined; }).call();"
},
{
"name": "\"this\" is not coerced to object in primitive methods",
"exec": "'use strict';\nreturn (function(){ return typeof this === 'string' }).call('')\n && (function(){ return typeof this === 'number' }).call(1)\n && (function(){ return typeof this === 'boolean' }).call(true);"
},
{
"name": "\"this\" is not coerced to object in primitive accessors",
"exec": "'use strict';\n\nfunction test(Class, instance) {\n Object.defineProperty(Class.prototype, 'test', {\n get: function () { passed = passed && this === instance; },\n set: function () { passed = passed && this === instance; },\n configurable: true\n });\n\n var passed = true;\n instance.test;\n instance.test = 42;\n return passed;\n}\n\nreturn test(String, '')\n && test(Number, 1)\n && test(Boolean, true);"
},
{
"name": "legacy octal is a SyntaxError",
"exec": "'use strict';\ntry { eval('010'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('\"\\\\010\"'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\nreturn true;"
},
{
"name": "assignment to unresolvable identifiers is a ReferenceError",
"exec": "'use strict';\ntry { eval('__i_dont_exist = 1'); } catch (err) { return err instanceof ReferenceError; }"
},
{
"name": "assignment to eval or arguments is a SyntaxError",
"exec": "'use strict';\ntry { eval('eval = 1'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('arguments = 1'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('eval++'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('arguments++'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\nreturn true;"
},
{
"name": "assignment to non-writable properties is a TypeError",
"exec": "'use strict';\ntry { Object.defineProperty({},\"x\",{ writable: false }).x = 1; return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\ntry { Object.preventExtensions({}).x = 1; return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\ntry { ({ get x(){ } }).x = 1; return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\ntry { (function f() { f = 123; })(); return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\nreturn true;"
},
{
"name": "eval or arguments bindings is a SyntaxError",
"exec": "'use strict';\ntry { eval('var eval'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('var arguments'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('(function(eval){})'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('(function(arguments){})'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('try{}catch(eval){}'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\ntry { eval('try{}catch(arguments){}'); return false; } catch (err) { if (!(err instanceof SyntaxError)) return false; }\nreturn true;"
},
{
"name": "arguments.caller removed or is a TypeError",
"exec": "'use strict';\nif ('caller' in arguments) {\n try { arguments.caller; return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\n}\nreturn true;"
},
{
"name": "arguments.callee is a TypeError",
"exec": "'use strict';\ntry { arguments.callee; return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\nreturn true;"
},
{
"name": "(function(){}).caller and (function(){}).arguments is a TypeError",
"exec": "'use strict';\ntry { (function(){}).caller; return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\ntry { (function(){}).arguments; return false; } catch (err) { if (!(err instanceof TypeError)) return false; }\nreturn true;"
},
{
"name": "arguments is unmapped",
"exec": "'use strict';\nreturn (function(x){\n x = 2;\n return arguments[0] === 1;\n})(1) && (function(x){\n arguments[0] = 2;\n return x === 1;\n})(1);"
},
{
"name": "eval() can't create bindings",
"exec": "'use strict';\ntry { eval('var __some_unique_variable;'); __some_unique_variable; } catch (err) { return err instanceof ReferenceError; }"
},
{
"name": "deleting bindings is a SyntaxError",
"exec": "'use strict';\ntry { eval('var x; delete x;'); } catch (err) { return err instanceof SyntaxError; }"
},
{
"name": "deleting non-configurable properties is a TypeError",
"exec": "'use strict';\ntry { delete Object.prototype; } catch (err) { return err instanceof TypeError; }"
},
{
"name": "\"with\" is a SyntaxError",
"exec": "'use strict';\ntry { eval('with({}){}'); } catch (err) { return err instanceof SyntaxError; }"
},
{
"name": "repeated parameter names is a SyntaxError",
"exec": "'use strict';\ntry { eval('function f(x, x) { }'); } catch (err) { return err instanceof SyntaxError; }"
},
{
"name": "function expressions with matching name and argument are valid",
"exec": "var foo = function bar(bar) {'use strict'};\nreturn typeof foo === 'function';"
}
]
},
{
"name": "proper tail calls (tail call optimisation)",
"target": "es6",
"category": "optimisation",
"significance": "medium",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-tail-position-calls",
"subtests": [
{
"name": "direct recursion",
"exec": "\"use strict\";\nreturn (function f(n){\n if (n <= 0) {\n return \"foo\";\n }\n return f(n - 1);\n}(1e6)) === \"foo\";"
},
{
"name": "mutual recursion",
"exec": "\"use strict\";\nfunction f(n){\n if (n <= 0) {\n return \"foo\";\n }\n return g(n - 1);\n}\nfunction g(n){\n if (n <= 0) {\n return \"bar\";\n }\n return f(n - 1);\n}\nreturn f(1e6) === \"foo\" && f(1e6+1) === \"bar\";"
}
]
},
{
"name": "default function parameters",
"target": "es6",
"category": "syntax",
"significance": "medium",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-functiondeclarationinstantiation",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters",
"subtests": [
{
"name": "basic functionality",
"exec": "return (function (a = 1, b = 2) { return a === 3 && b === 2; }(3));"
},
{
"name": "explicit undefined defers to the default",
"exec": "return (function (a = 1, b = 2) { return a === 1 && b === 3; }(undefined, 3));"
},
{
"name": "defaults can refer to previous params",
"exec": "return (function (a, b = a) { return b === 5; }(5));"
},
{
"name": "arguments object interaction",
"exec": "return (function (a = \"baz\", b = \"qux\", c = \"quux\") {\n a = \"corge\";\n // The arguments object is not mapped to the\n // parameters, even outside of strict mode.\n return arguments.length === 2\n && arguments[0] === \"foo\"\n && arguments[1] === \"bar\";\n}(\"foo\", \"bar\"));"
},
{
"name": "temporal dead zone",
"exec": "return (function(x = 1) {\n try {\n eval(\"(function(a=a){}())\");\n return false;\n } catch(e) {}\n try {\n eval(\"(function(a=b,b){}())\");\n return false;\n } catch(e) {}\n return true;\n}());"
},
{
"name": "separate scope",
"exec": "return (function(a=function(){\n return typeof b === 'undefined';\n}){\n var b = 1;\n return a();\n}());"
},
{
"name": "new Function() support",
"exec": "return new Function(\"a = 1\", \"b = 2\",\n \"return a === 3 && b === 2;\"\n)(3);"
}
]
},
{
"name": "rest parameters",
"target": "es6",
"category": "syntax",
"significance": "medium",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-function-definitions",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters",
"subtests": [
{
"name": "basic functionality",
"exec": "return (function (foo, ...args) {\n return args instanceof Array && args + \"\" === \"bar,baz\";\n}(\"foo\", \"bar\", \"baz\"));"
},
{
"name": "function 'length' property",
"exec": "return function(a, ...b){}.length === 1 && function(...c){}.length === 0;"
},
{
"name": "arguments object interaction",
"exec": "return (function (foo, ...args) {\n foo = \"qux\";\n // The arguments object is not mapped to the\n // parameters, even outside of strict mode.\n return arguments.length === 3\n && arguments[0] === \"foo\"\n && arguments[1] === \"bar\"\n && arguments[2] === \"baz\";\n}(\"foo\", \"bar\", \"baz\"));"
},
{
"name": "can't be used in setters",
"exec": "return (function (...args) {\n try {\n eval(\"({set e(...args){}})\");\n } catch(e) {\n return true;\n }\n}());"
},
{
"name": "new Function() support",
"exec": "return new Function(\"a\", \"...b\",\n \"return b instanceof Array && a+b === 'foobar,baz';\"\n)('foo','bar','baz');"
}
]
},
{
"name": "spread syntax for iterable objects",
"target": "es6",
"category": "syntax",
"significance": "large",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-argument-lists-runtime-semantics-argumentlistevaluation",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator",
"subtests": [
{
"name": "with arrays, in function calls",
"exec": "return Math.max(...[1, 2, 3]) === 3"
},
{
"name": "with arrays, in array literals",
"exec": "return [...[1, 2, 3]][2] === 3;"
},
{
"name": "with sparse arrays, in function calls",
"exec": "var a = Array(...[,,]);\nreturn \"0\" in a && \"1\" in a && '' + a[0] + a[1] === \"undefinedundefined\";"
},
{
"name": "with sparse arrays, in array literals",
"exec": "var a = [...[,,]];\nreturn \"0\" in a && \"1\" in a && '' + a[0] + a[1] === \"undefinedundefined\";"
},
{
"name": "with strings, in function calls",
"exec": "return Math.max(...\"1234\") === 4;"
},
{
"name": "with strings, in array literals",
"exec": "return [\"a\", ...\"bcd\", \"e\"][3] === \"d\";"
},
{
"name": "with astral plane strings, in function calls",
"exec": "return Array(...\"𠮷𠮶\")[0] === \"𠮷\";"
},
{
"name": "with astral plane strings, in array literals",
"exec": "return [...\"𠮷𠮶\"][0] === \"𠮷\";"
},
{
"name": "with generator instances, in calls",
"exec": "var iterable = (function*(){ yield 1; yield 2; yield 3; }());\nreturn Math.max(...iterable) === 3;"
},
{
"name": "with generator instances, in arrays",
"exec": "var iterable = (function*(){ yield \"b\"; yield \"c\"; yield \"d\"; }());\nreturn [\"a\", ...iterable, \"e\"][3] === \"d\";"
},
{
"name": "with generic iterables, in calls",
"exec": "var iterable = global.__createIterableObject([1, 2, 3]);\nreturn Math.max(...iterable) === 3;"
},
{
"name": "with generic iterables, in arrays",
"exec": "var iterable = global.__createIterableObject([\"b\", \"c\", \"d\"]);\nreturn [\"a\", ...iterable, \"e\"][3] === \"d\";"
},
{
"name": "with instances of iterables, in calls",
"exec": "var iterable = global.__createIterableObject([1, 2, 3]);\nreturn Math.max(...Object.create(iterable)) === 3;"
},
{
"name": "with instances of iterables, in arrays",
"exec": "var iterable = global.__createIterableObject([\"b\", \"c\", \"d\"]);\nreturn [\"a\", ...Object.create(iterable), \"e\"][3] === \"d\";"
},
{
"name": "spreading non-iterables is a runtime error",
"exec": "try {\n Math.max(...2);\n} catch(e) {\n return Math.max(...[1, 2, 3]) === 3;\n}"
}
]
},
{
"name": "object literal extensions",
"target": "es6",
"category": "syntax",
"significance": "large",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-object-initialiser",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_2015",
"subtests": [
{
"name": "computed properties",
"exec": "var x = 'y';\nreturn ({ [x]: 1 }).y === 1;"
},
{
"name": "shorthand properties",
"exec": "var a = 7, b = 8, c = {a,b};\nreturn c.a === 7 && c.b === 8;"
},
{
"name": "shorthand methods",
"exec": "return ({ y() { return 2; } }).y() === 2;"
},
{
"name": "string-keyed shorthand methods",
"exec": "return ({ \"foo bar\"() { return 4; } })[\"foo bar\"]() === 4;"
},
{
"name": "computed shorthand methods",
"exec": "var x = 'y';\nreturn ({ [x](){ return 1 } }).y() === 1;"
},
{
"name": "computed accessors",
"exec": "var x = 'y',\n valueSet,\n obj = {\n get [x] () { return 1 },\n set [x] (value) { valueSet = value }\n };\nobj.y = 'foo';\nreturn obj.y === 1 && valueSet === 'foo';"
}
]
},
{
"name": "for..of loops",
"target": "es6",
"category": "syntax",
"significance": "large",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-for-in-and-for-of-statements",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of",
"subtests": [
{
"name": "with arrays",
"exec": "var arr = [5];\nfor (var item of arr)\n return item === 5;"
},
{
"name": "with sparse arrays",
"exec": "var arr = [,,];\nvar count = 0;\nfor (var item of arr)\n count += (item === void undefined);\nreturn count === 2;"
},
{
"name": "with strings",
"exec": "var str = \"\";\nfor (var item of \"foo\")\n str += item;\nreturn str === \"foo\";"
},
{
"name": "with astral plane strings",
"exec": "var str = \"\";\nfor (var item of \"𠮷𠮶\")\n str += item + \" \";\nreturn str === \"𠮷 𠮶 \";"
},
{
"name": "with generator instances",
"exec": "var result = \"\";\nvar iterable = (function*(){ yield 1; yield 2; yield 3; }());\nfor (var item of iterable) {\n result += item;\n}\nreturn result === \"123\";"
},
{
"name": "with generic iterables",
"exec": "var result = \"\";\nvar iterable = global.__createIterableObject([1, 2, 3]);\nfor (var item of iterable) {\n result += item;\n}\nreturn result === \"123\";"
},
{
"name": "with instances of generic iterables",
"exec": "var result = \"\";\nvar iterable = global.__createIterableObject([1, 2, 3]);\nfor (var item of Object.create(iterable)) {\n result += item;\n}\nreturn result === \"123\";"
},
{
"name": "iterator closing, break",
"exec": "var closed = false;\nvar iter = __createIterableObject([1, 2, 3], {\n 'return': function(){ closed = true; return {}; }\n});\nfor (var it of iter) break;\nreturn closed;"
},
{
"name": "iterator closing, throw",
"exec": "var closed = false;\nvar iter = __createIterableObject([1, 2, 3], {\n 'return': function(){ closed = true; return {}; }\n});\ntry {\n for (var it of iter) throw 0;\n} catch(e){}\nreturn closed;"
}
]
},
{
"name": "octal and binary literals",
"target": "es6",
"category": "syntax",
"significance": "small",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-literals-numeric-literals",
"subtests": [
{
"name": "octal literals",
"exec": "return 0o10 === 8 && 0O10 === 8;"
},
{
"name": "binary literals",
"exec": "return 0b10 === 2 && 0B10 === 2;"
},
{
"name": "octal supported by Number()",
"exec": "return Number('0o1') === 1;"
},
{
"name": "binary supported by Number()",
"exec": "return Number('0b1') === 1;"
}
]
},
{
"name": "template literals",
"target": "es6",
"category": "syntax",
"significance": "large",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-template-literals",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals",
"subtests": [
{
"name": "basic functionality",
"exec": "var a = \"ba\", b = \"QUX\";\nreturn `foo bar\n${a + \"z\"} ${b.toLowerCase()}` === \"foo bar\\nbaz qux\";"
},
{
"name": "toString conversion",
"exec": "var a = {\n toString: function() { return \"foo\"; },\n valueOf: function() { return \"bar\"; }\n};\nreturn `${a}` === \"foo\";"
},
{
"name": "tagged template literals",
"exec": "var called = false;\nfunction fn(parts, a, b) {\n called = true;\n return parts instanceof Array &&\n parts[0] === \"foo\" &&\n parts[1] === \"bar\\n\" &&\n parts.raw[0] === \"foo\" &&\n parts.raw[1] === \"bar\\\\n\" &&\n a === 123 &&\n b === 456;\n}\nreturn fn `foo${123}bar\\n${456}` && called;"
},
{
"name": "passed array is frozen",
"exec": "return (function(parts) {\n return Object.isFrozen(parts) && Object.isFrozen(parts.raw);\n}) `foo${0}bar${0}baz`;"
},
{
"name": "line break normalisation",
"exec": "var cr = eval(\"`x\" + String.fromCharCode(13) + \"y`\");\nvar lf = eval(\"`x\" + String.fromCharCode(10) + \"y`\");\nvar crlf = eval(\"`x\" + String.fromCharCode(13,10) + \"y`\");\n\nreturn cr.length === 3 && lf.length === 3 && crlf.length === 3\n && cr[1] === lf[1] && lf[1] === crlf[1] && crlf[1] === '\\n';"
},
{
"name": "TemplateStrings call site caching",
"exec": "// TemplateStrings caching was changed from per-contents to\n// per-call-site.\n// https://github.com/tc39/ecma262/pull/890\nfunction strings(array) {\n return array;\n}\nfunction getStrings() {\n return strings`foo`;\n}\nvar original = getStrings();\nvar other = strings`foo`;\nreturn original === getStrings() && original !== other;"
},
{
"name": "TemplateStrings permanent caching",
"exec": "function strings(array) {\n return array;\n}\nfunction getStrings() {\n return strings`foo`;\n}\nvar original = getStrings();\nvar newed = new getStrings();\nreturn original === getStrings() && original === newed;"
}
]
},
{
"name": "RegExp \"y\" and \"u\" flags",
"target": "es6",
"category": "syntax",
"significance": "medium",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.sticky",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Parameters",
"subtests": [
{
"name": "\"y\" flag",
"exec": "var re = new RegExp('\\\\w', 'y');\nre.exec('xy');\nreturn (re.exec('xy')[0] === 'y');"
},
{
"name": "\"y\" flag, lastIndex",
"exec": "var re = new RegExp('yy', 'y');\nre.lastIndex = 3;\nvar result = re.exec('xxxyyxx')[0];\nreturn result === 'yy' && re.lastIndex === 5;"
},
{
"name": "\"u\" flag",
"exec": "return \"𠮷\".match(/^.$/u)[0].length === 2;"
},
{
"name": "\"u\" flag, non-BMP Unicode characters",
"exec": "return \"𠮷x\".match(/^.x$/u)[0].length === 3;"
},
{
"name": "\"u\" flag, Unicode code point escapes",
"exec": "return \"𝌆\".match(/\\u{1d306}/u)[0].length === 2;"
},
{
"name": "\"u\" flag, case folding",
"exec": "return \"ſ\".match(/S/iu) && \"S\".match(/ſ/iu);"
}
]
},
{
"name": "destructuring, declarations",
"target": "es6",
"category": "syntax",
"significance": "medium",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment",
"subtests": [
{
"name": "with arrays",
"exec": "var [a, , [b], c] = [5, null, [6]];\nreturn a === 5 && b === 6 && c === void undefined;"
},
{
"name": "with sparse arrays",
"exec": "var [a, , b] = [,,,];\nreturn a === void undefined && b === void undefined;"
},
{
"name": "with strings",
"exec": "var [a, b, c] = \"ab\";\nreturn a === \"a\" && b === \"b\" && c === void undefined;"
},
{
"name": "with astral plane strings",
"exec": "var [c] = \"𠮷𠮶\";\nreturn c === \"𠮷\";"
},
{
"name": "with generator instances",
"exec": "var [a, b, c] = (function*(){ yield 1; yield 2; }());\nreturn a === 1 && b === 2 && c === void undefined;"
},
{
"name": "with generic iterables",
"exec": "var [a, b, c] = global.__createIterableObject([1, 2]);\nreturn a === 1 && b === 2 && c === void undefined;"
},
{
"name": "with instances of generic iterables",
"exec": "var [a, b, c] = Object.create(global.__createIterableObject([1, 2]));\nreturn a === 1 && b === 2 && c === void undefined;"
},
{
"name": "iterator closing",
"exec": "var closed = false;\nvar iter = global.__createIterableObject([1, 2, 3], {\n 'return': function(){ closed = true; return {}; }\n});\nvar [a, b] = iter;\nreturn closed;"
},
{
"name": "trailing commas in iterable patterns",
"exec": "var [a,] = [1];\nreturn a === 1;"
},
{
"name": "with objects",
"exec": "var {c, x:d, e} = {c:7, x:8};\nreturn c === 7 && d === 8 && e === void undefined;"
},
{
"name": "object destructuring with primitives",
"exec": "var {toFixed} = 2;\nvar {slice} = '';\nreturn toFixed === Number.prototype.toFixed\n && slice === String.prototype.slice;"
},
{
"name": "trailing commas in object patterns",
"exec": "var {a,} = {a:1};\nreturn a === 1;"
},
{
"name": "throws on null and undefined",
"exec": "try {\n var {a} = null;\n return false;\n} catch(e) {\n if (!(e instanceof TypeError))\n return false;\n}\ntry {\n var {b} = void undefined;\n return false;\n} catch(e) {\n if (!(e instanceof TypeError))\n return false;\n}\nreturn true;"
},
{
"name": "computed properties",
"exec": "var qux = \"corge\";\nvar { [qux]: grault } = { corge: \"garply\" };\nreturn grault === \"garply\";"
},
{
"name": "multiples in a single var statement",
"exec": "var [a,b] = [5,6], {c,d} = {c:7,d:8};\nreturn a === 5 && b === 6 && c === 7 && d === 8;"
},
{
"name": "nested",
"exec": "var [e, {x:f, g}] = [9, {x:10}];\nvar {h, x:[i]} = {h:11, x:[12]};\nreturn e === 9 && f === 10 && g === void undefined\n && h === 11 && i === 12;"
},
{
"name": "in for-in loop heads",
"exec": "for(var [i, j, k] in { qux: 1 }) {\n return i === \"q\" && j === \"u\" && k === \"x\";\n}"
},
{
"name": "in for-of loop heads",
"exec": "for(var [i, j, k] of [[1,2,3]]) {\n return i === 1 && j === 2 && k === 3;\n}"
},
{
"name": "in catch heads",
"exec": "try {\n throw [1,2];\n} catch([i,j]) {\n try {\n throw { k: 3, l: 4 };\n } catch({k, l}) {\n return i === 1 && j === 2 && k === 3 && l === 4;\n }\n}"
},
{
"name": "rest",
"exec": "var [a, ...b] = [3, 4, 5];\nvar [c, ...d] = [6];\nreturn a === 3 && b instanceof Array && (b + \"\") === \"4,5\" &&\n c === 6 && d instanceof Array && d.length === 0;"
},
{
"name": "defaults",
"exec": "var {a = 1, b = 0, z:c = 3} = {b:2, z:undefined};\nvar [d = 0, e = 5, f = 6] = [4,,undefined];\nreturn a === 1 && b === 2 && c === 3\n && d === 4 && e === 5 && f === 6;"
},
{
"name": "defaults, let temporal dead zone",
"exec": "var {a, b = 2} = {a:1};\ntry {\n eval(\"let {c = c} = {};\");\n return false;\n} catch(e){}\ntry {\n eval(\"let {c = d, d} = {d:1};\");\n return false;\n} catch(e){}\nreturn a === 1 && b === 2;"
}
]
},
{
"name": "destructuring, assignment",
"target": "es6",
"category": "syntax",
"significance": "medium",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment",
"subtests": [
{
"name": "with arrays",
"exec": "var a,b,c;\n[a, , [b], c] = [5, null, [6]];\nreturn a === 5 && b === 6 && c === void undefined;"
},
{
"name": "with sparse arrays",
"exec": "var a, b;\n[a, , b] = [,,,];\nreturn a === void undefined && b === void undefined;"
},
{
"name": "with strings",
"exec": "var a,b,c;\n[a, b, c] = \"ab\";\nreturn a === \"a\" && b === \"b\" && c === void undefined;"
},
{
"name": "with astral plane strings",
"exec": "var c;\n[c] = \"𠮷𠮶\";\nreturn c === \"𠮷\";"
},
{
"name": "with generator instances",
"exec": "var a,b,c;\n[a, b, c] = (function*(){ yield 1; yield 2; }());\nreturn a === 1 && b === 2 && c === void undefined;"
},
{
"name": "with generic iterables",
"exec": "var a,b,c;\n[a, b, c] = global.__createIterableObject([1, 2]);\nreturn a === 1 && b === 2 && c === void undefined;"
},
{
"name": "with instances of generic iterables",
"exec": "var a,b,c;\n[a, b, c] = Object.create(global.__createIterableObject([1, 2]));\nreturn a === 1 && b === 2 && c === void undefined;"
},
{
"name": "iterator closing",
"exec": "var closed = false;\nvar iter = global.__createIterableObject([1, 2, 3], {\n 'return': function(){ closed = true; return {}; }\n});\nvar a,b;\n[a, b] = iter;\nreturn closed;"
},
{
"name": "iterable destructuring expression",
"exec": "var a, b, iterable = [1,2];\nreturn ([a, b] = iterable) === iterable;"
},
{
"name": "chained iterable destructuring",
"exec": "var a,b,c,d;\n[a,b] = [c,d] = [1,2];\nreturn a === 1 && b === 2 && c === 1 && d === 2;"
},
{
"name": "trailing commas in iterable patterns",
"exec": "var a;\n[a,] = [1];\nreturn a === 1;"
},
{
"name": "with objects",
"exec": "var c,d,e;\n({c, x:d, e} = {c:7, x:8});\nreturn c === 7 && d === 8 && e === void undefined;"
},
{
"name": "object destructuring with primitives",
"exec": "var toFixed, slice;\n({toFixed} = 2);\n({slice} = '');\nreturn toFixed === Number.prototype.toFixed\n && slice === String.prototype.slice;"
},
{
"name": "trailing commas in object patterns",
"exec": "var a;\n({a,} = {a:1});\nreturn a === 1;"
},
{
"name": "object destructuring expression",
"exec": "var a, b, obj = { a:1, b:2 };\nreturn ({a,b} = obj) === obj;"
},
{
"name": "parenthesised left-hand-side is a syntax error",
"exec": "var a, b;\n({a,b} = {a:1,b:2});\ntry {\n eval(\"({a,b}) = {a:3,b:4};\");\n}\ncatch(e) {\n return a === 1 && b === 2;\n}"
},
{
"name": "chained object destructuring",
"exec": "var a,b,c,d;\n({a,b} = {c,d} = {a:1,b:2,c:3,d:4});\nreturn a === 1 && b === 2 && c === 3 && d === 4;"
},
{
"name": "throws on null and undefined",
"exec": "var a,b;\ntry {\n ({a} = null);\n return false;\n} catch(e) {\n if (!(e instanceof TypeError))\n return false;\n}\ntry {\n ({b} = void undefined);\n return false;\n} catch(e) {\n if (!(e instanceof TypeError))\n return false;\n}\nreturn true;"
},
{
"name": "computed properties",
"exec": "var grault, qux = \"corge\";\n({ [qux]: grault } = { corge: \"garply\" });\nreturn grault === \"garply\";"
},
{
"name": "nested",
"exec": "var e,f,g,h,i;\n[e, {x:f, g}] = [9, {x:10}];\n({h, x:[i]} = {h:11, x:[12]});\nreturn e === 9 && f === 10 && g === void undefined\n && h === 11 && i === 12;"
},
{
"name": "rest",
"exec": "var a,b,c,d;\n[a, ...b] = [3, 4, 5];\n[c, ...d] = [6];\nreturn a === 3 && b instanceof Array && (b + \"\") === \"4,5\" &&\n c === 6 && d instanceof Array && d.length === 0;"
},
{
"name": "nested rest",
"exec": "var a = [1, 2, 3], first, last;\n[first, ...[a[2], last]] = a;\nreturn first === 1 && last === 3 && (a + \"\") === \"1,2,2\";"
},
{
"name": "empty patterns",
"exec": "[] = [1,2];\n({} = {a:1,b:2});\nreturn true;"
},
{
"name": "defaults",
"exec": "var a,b,c,d,e,f;\n({a = 1, b = 0, z:c = 3} = {b:2, z:undefined});\n[d = 0, e = 5, f = 6] = [4,,undefined];\nreturn a === 1 && b === 2 && c === 3\n && d === 4 && e === 5 && f === 6;"
}
]
},
{
"name": "destructuring, parameters",
"target": "es6",
"category": "syntax",
"significance": "medium",
"spec": "http://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment",
"mdn": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment",
"subtests": [
{
"name": "with arrays",
"exec": "return function([a, , [b], c]) {\n return a === 5 && b === 6 && c === void undefined;\n}([5, null, [6]]);"
},
{
"name": "with sparse arrays",
"exec": "return function([a, , b]) {\n return a === void undefined && b === void undefined;\n}([,,,]);"
},
{
"name": "with strings",
"exec": "return function([a, b, c]) {\n return a === \"a\" && b === \"b\" && c === void undefined;\n}(\"ab\");"
},
{
"name": "with astral plane strings",
"exec": "return function([c]) {\n return c === \"𠮷\";\n}(\"𠮷𠮶\");"
},
{
"name": "with generator instances",
"exec": "return function([a, b, c]) {\n return a === 1 && b === 2 && c === void undefined;\n}(function*(){ yield 1; yield 2; }());"
},
{
"name": "with generic iterables",
"exec": "return function([a, b, c]) {\n return a === 1 && b === 2 && c === void undefined;\n}(global.__createIterableObject([1, 2]));"
},
{
"name": "with instances of generic iterables",
"exec": "return function([a, b, c]) {\n return a === 1 && b === 2 && c === void undefined;\n}(Object.create(global.__createIterableObject([1, 2])));"
},
{
"name": "iterator closing",
"exec": "var closed = false;\nvar iter = global.__createIterableObject([1, 2, 3], {\n 'return': function(){ closed = true; return {}; }\n});\n(function([a,b]) {}(iter));\nreturn closed;"
},
{
"name": "trailing commas in iterable patterns",
"exec": "return function([a,]) {\n return a === 1;\n}([1]);"
},
{
"name": "with objects",
"exec": "return function({c, x:d, e}) {\n return c === 7 && d === 8 && e === void undefined;\n}({c:7, x:8});"
},
{
"name": "object destructuring with primitives",
"exec": "return function({toFixed}, {slice}) {\n return toFixed === Number.prototype.toFixed\n && slice === String.prototype.slice;\n}(2,'');"
},
{
"name": "trailing commas in object patterns",
"exec": "return function({a,}) {\n return a === 1;\n}({a:1});"
},
{
"name": "throws on null and undefined",
"exec": "try {\n (function({a}){}(null));\n return false;\n} catch(e) {}\ntry {\n (function({b}){}(undefined));\n return false;\n} catch(e) {}\nreturn true;"
},
{
"name": "computed properties",
"exec": "var qux = \"corge\";\nreturn function({ [qux]: grault }) {\n return grault === \"garply\";\n}({ corge: \"garply\" });"
},
{
"name": "nested",
"exec": "return function([e, {x:f, g}], {h, x:[i]}) {\n return e === 9 && f === 10 && g === void undefined\n && h === 11 && i === 12;\n}([9, {x:10}],{h:11, x:[12]});"
},
{
"name": "'arguments' interaction",
"exec": "return (function({a, x:b, y:e}, [c, d]) {\n return arguments[0].a === 1 && arguments[0].x === 2\n && !(\"y\" in arguments[0]) && arguments[1] + '' === \"3,4\";\n}({a:1, x:2}, [3, 4]));"