Debian Codegraph @

js/src/tests/test262/built-ins/Iterator/from/supports-iterator.js

raw
1 // |reftest| shell-option(--enable-iterator-helpers) skip-if(!this.hasOwnProperty('Iterator')||!xulRuntime.shell) -- iterator-helpers is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2023 Michael Ficarra. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-iterator.from
6 description: >
7 Iterator.from supports non-iterable iterators
8 info: |
9 Iterator.from ( O )
10
11 includes: [compareArray.js]
12 features: [iterator-helpers]
13 flags: []
14 ---*/
15
16 function* g() {
17 yield 0;
18 yield 1;
19 yield 2;
20 yield 3;
21 }
22
23 let n = g();
24 let iter = {
25 next() {
26 return n.next();
27 },
28 };
29
30 assert.compareArray(Array.from(Iterator.from(iter)), [0, 1, 2, 3]);
31
32 reportCompare(0, 0);