]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/array-iterators-next.js
1 // This test checks the behavior of the iterator.next methods on Array objects
3 var testArray
= [1,2,3,4,5,6]
4 var keys
= testArray
.keys();
7 var {done
, value: key
} = keys
.next();
11 throw "Error: bad value: " + key
;
15 if (testArray
.length
!== i
)
16 throw "Error: bad value: " + i
;
18 var value
= keys
.next().value
;
19 if (value
!== undefined)
20 throw "Error: bad value: " + value
;
22 var values
= testArray
[Symbol
.iterator
]();
25 var {done
, value
} = values
.next();
30 throw "Error: bad value: " + value
;
33 if (testArray
.length
!== i
)
34 throw "Error: bad value: " + i
;
36 var value
= values
.next().value
;
37 if (value
!== undefined)
38 throw "Error: bad value: " + value
;
40 var values
= testArray
.values();
43 var {done
, value
} = values
.next();
48 throw "Error: bad value: " + value
;
51 if (testArray
.length
!== i
)
52 throw "Error: bad value: " + i
;
54 var value
= values
.next().value
;
55 if (value
!== undefined)
56 throw "Error: bad value: " + value
;
58 var entries
= testArray
.entries();
61 var {done
, value: entry
} = entries
.next();
64 var [key
, value
] = entry
;
65 if (value
!== testArray
[key
])
66 throw "Error: bad value: " + value
+ " " + testArray
[key
];
68 throw "Error: bad value: " + key
;
71 throw "Error: bad value: " + value
+ " " + i
;
74 if (testArray
.length
!== i
)
75 throw "Error: bad value: " + i
;
77 var value
= entries
.next().value
;
78 if (value
!== undefined)
79 throw "Error: bad value: " + value
;
81 var entries
= testArray
.entries();
84 var {done
, value: entry
} = entries
.next();
87 var [key
, value
] = entry
;
88 if (value
!== testArray
[key
])
89 throw "Error: bad value: " + value
+ " " + testArray
[key
];
91 throw "Error: bad value: " + key
;
96 testArray
.push(testArray
.length
)
103 if (testArray
.length
!== i
)
104 throw "Error: bad value: " + i
;
106 var value
= entries
.next().value
;
107 if (value
!== undefined)
108 throw "Error: bad value: " + value
;