1 // Copyright (C) 2024 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
7 Modifications to input array after iteration are handled correctly.
14 b. If firstArgument is an Object, then
18 2. Let usingIterator be ? GetMethod(firstArgument, @@iterator).
19 3. If usingIterator is not undefined, then
20 a. Let values be ? IteratorToList(? GetIteratorFromMethod(firstArgument, usingIterator)).
21 b. Perform ? InitializeTypedArrayFromList(O, values).
23 includes: [testTypedArray.js]
24 features: [TypedArray]
27 let ArrayIteratorPrototype = Object.getPrototypeOf([].values());
30 // Modify the built-in ArrayIteratorPrototype `next` method.
31 ArrayIteratorPrototype.next = function() {
32 let done = values.length === 0;
33 let value = values.pop();
37 testWithTypedArrayConstructors(function(TypedArray) {
38 // Reset `values` array.
39 values = [1, 2, 3, 4];
41 // Constructor called with array which uses the modified array iterator.
42 var ta = new TypedArray([0]);
44 assert.sameValue(ta.length, 4);
45 assert.sameValue(ta[0], 4);
46 assert.sameValue(ta[1], 3);
47 assert.sameValue(ta[2], 2);
48 assert.sameValue(ta[3], 1);