blob: 0b266e9897a7178823fa1ee68f9b0aea7d196910 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5var arrayIteratorPrototype = [].entries().__proto__;
6var iteratorPrototype = arrayIteratorPrototype.__proto__;
7
8assertSame(Object.prototype, Object.getPrototypeOf(iteratorPrototype));
9assertTrue(Object.isExtensible(iteratorPrototype));
10assertSame(0, Object.getOwnPropertyNames(iteratorPrototype).length);
11assertSame(1, Object.getOwnPropertySymbols(iteratorPrototype).length);
12assertSame(Symbol.iterator,
13 Object.getOwnPropertySymbols(iteratorPrototype)[0]);
14
15var descr = Object.getOwnPropertyDescriptor(iteratorPrototype, Symbol.iterator);
16assertTrue(descr.configurable);
17assertFalse(descr.enumerable);
18assertTrue(descr.writable);
19
20var iteratorFunction = descr.value;
21assertSame('function', typeof iteratorFunction);
22assertSame(0, iteratorFunction.length);
23assertSame('[Symbol.iterator]', iteratorFunction.name);
24
25var obj = {};
26assertSame(obj, iteratorFunction.call(obj));
27assertSame(iteratorPrototype, iteratorPrototype[Symbol.iterator]());
28
29var mapIteratorPrototype = new Map().entries().__proto__;
30var setIteratorPrototype = new Set().values().__proto__;
31var stringIteratorPrototype = 'abc'[Symbol.iterator]().__proto__;
32assertSame(iteratorPrototype, mapIteratorPrototype.__proto__);
33assertSame(iteratorPrototype, setIteratorPrototype.__proto__);
34assertSame(iteratorPrototype, stringIteratorPrototype.__proto__);
35
36var typedArrays = [
37 Float32Array,
38 Float64Array,
39 Int16Array,
40 Int32Array,
41 Int8Array,
42 Uint16Array,
43 Uint32Array,
44 Uint8Array,
45 Uint8ClampedArray,
46];
47
48for (var constructor of typedArrays) {
49 var array = new constructor();
50 var iterator = array[Symbol.iterator]();
51 assertSame(iteratorPrototype, iterator.__proto__.__proto__);
52}
53
54function* gen() {}
55assertSame(iteratorPrototype, gen.prototype.__proto__.__proto__);
56var g = gen();
57assertSame(gen.prototype, g.__proto__);
58assertSame(iteratorPrototype, g.__proto__.__proto__.__proto__);