next-method-called-with-zero-arguments.js (1328B)
1 // |reftest| shell-option(--enable-iterator-sequencing) skip-if(!Iterator.concat||!xulRuntime.shell) -- iterator-sequencing is not enabled unconditionally, requires shell-options 2 // Copyright (C) 2024 André Bargull. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-iterator.concat 7 description: > 8 Underlying iterator's next method is called with zero arguments. 9 info: | 10 Iterator.concat ( ...items ) 11 12 ... 13 3. Let closure be a new Abstract Closure with no parameters that captures iterables and performs the following steps when called: 14 a. For each Record iterable of iterables, do 15 ... 16 v. Repeat, while innerAlive is true, 17 1. Let innerValue be ? IteratorStepValue(iteratorRecord). 18 ... 19 features: [iterator-sequencing] 20 ---*/ 21 22 let nextCalled = 0; 23 24 let testIterator = { 25 next() { 26 nextCalled++; 27 assert.sameValue(arguments.length, 0); 28 29 return { 30 done: false, 31 value: 0, 32 }; 33 } 34 }; 35 36 let iterable = { 37 [Symbol.iterator]() { 38 return testIterator; 39 } 40 }; 41 42 let iterator = Iterator.concat(iterable); 43 assert.sameValue(nextCalled, 0); 44 45 iterator.next(); 46 assert.sameValue(nextCalled, 1); 47 48 iterator.next(1); 49 assert.sameValue(nextCalled, 2); 50 51 iterator.next(1, 2); 52 assert.sameValue(nextCalled, 3); 53 54 reportCompare(0, 0);