many-arguments.js (1321B)
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 Iterator.concat when called with many arguments. 9 info: | 10 Iterator.concat ( ...items ) 11 12 1. Let iterables be a new empty List. 13 2. For each element item of items, do 14 ... 15 3. Let closure be a new Abstract Closure with no parameters that captures iterables and performs the following steps when called: 16 a. For each Record iterable of iterables, do 17 ... 18 b. Return ReturnCompletion(undefined). 19 ... 20 6. Return gen. 21 features: [iterator-sequencing] 22 ---*/ 23 24 let iterables = [ 25 [/* empty */], 26 [1], 27 [2, 3], 28 [4, 5, 6], 29 [7, 8, 9, 10], 30 ]; 31 32 let iterator = Iterator.concat(...iterables); 33 34 let array = [].concat(...iterables); 35 36 for (let i = 0; i < array.length; i++) { 37 let iterResult = iterator.next(); 38 39 assert.sameValue(iterResult.done, false); 40 assert.sameValue(iterResult.value, array[i]); 41 } 42 43 let iterResult = iterator.next(); 44 45 assert.sameValue(iterResult.done, true); 46 assert.sameValue(iterResult.value, undefined); 47 48 reportCompare(0, 0);