Debian Codegraph @

js/src/tests/test262/built-ins/Iterator/from/result-proto.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 The value of the [[Prototype]] internal slot of the return value of Iterator.from is the
8 intrinsic object %WrapForValidIteratorPrototype%, whose [[Prototype]] is %IteratorHelperPrototype%.
9 features: [iterator-helpers]
10 ---*/
11 let iter = {
12 next() {
13 return {
14 done: true,
15 value: undefined,
16 };
17 },
18 };
19
20 const WrapForValidIteratorPrototype = Object.getPrototypeOf(Iterator.from(iter));
21
22 assert.sameValue(Object.getPrototypeOf(WrapForValidIteratorPrototype), Iterator.prototype);
23
24 class SubIterator extends Iterator {}
25 assert.sameValue(Object.getPrototypeOf(SubIterator.from(iter)), WrapForValidIteratorPrototype);
26
27 function* g() {}
28 const GeneratorPrototype = Object.getPrototypeOf(g());
29
30 assert.sameValue(Object.getPrototypeOf(Iterator.from(g())), GeneratorPrototype);
31
32 reportCompare(0, 0);