Debian Codegraph @

js/src/tests/test262/built-ins/Iterator/concat/single-argument.js

raw
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 a single argument.
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 array = [1, 2, 3];
25
26 let iterator = Iterator.concat(array);
27
28 for (let i = 0; i < array.length; i++) {
29 let iterResult = iterator.next();
30
31 assert.sameValue(iterResult.done, false);
32 assert.sameValue(iterResult.value, array[i]);
33 }
34
35 let iterResult = iterator.next();
36
37 assert.sameValue(iterResult.done, true);
38 assert.sameValue(iterResult.value, undefined);
39
40 reportCompare(0, 0);