blob: 05e51660986b93bd530ad57ec7352ef361de9ece [file] [log] [blame]
keith_miller@apple.com1618c2d2016-06-14 22:34:09 +00001// This tests that the lazy watchpoints we set for Symbol.species in our Builtin arrayPrototype functions work.
2
3
4function test(array) {
5 array = array.splice(2, 2);
6 array = array.slice(0, 5);
7 array = array.concat([1,2,3]);
8 return array;
9}
10noInline(test);
11
12function arrayEq(a, b) {
13 if (a.length !== b.length)
14 throw new Error();
15
16 for (let i = 0; i < a.length; i++) {
17 if (a[i] !== b[i])
18 throw new Error();
19 }
20}
21
22for (let i = 0; i < 100; i++)
23 arrayEq(test([1,2,3,4,5,6,7,8,9]), [3,4,1,2,3]);
24
25class A extends Array { }
26
27for (let i = 0; i < 100; i++) {
28 let result = test(new A(1,2,3,4,5,6,7,8,9));
29 arrayEq(result, [3,4,1,2,3]);
30 if (!(result instanceof A))
31 throw new Error();
32}
33
34for (let i = 0; i < 100; i++)
35 arrayEq(test([1,2,3,4,5,6,7,8,9]), [3,4,1,2,3]);
36
37delete Array.prototype.sort;
38
39for (let i = 0; i < 100; i++)
40 arrayEq(test([1,2,3,4,5,6,7,8,9]), [3,4,1,2,3]);
41
42for (let i = 0; i < 100; i++) {
43 let result = test(new A(1,2,3,4,5,6,7,8,9));
44 arrayEq(result, [3,4,1,2,3]);
45 if (!(result instanceof A))
46 throw new Error();
47}