OLD | NEW |
(Empty) | |
| 1 // 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 |
| 5 var arrayIteratorPrototype = [].entries().__proto__; |
| 6 var iteratorPrototype = arrayIteratorPrototype.__proto__; |
| 7 |
| 8 assertSame(Object.prototype, Object.getPrototypeOf(iteratorPrototype)); |
| 9 assertTrue(Object.isExtensible(iteratorPrototype)); |
| 10 assertSame(0, Object.getOwnPropertyNames(iteratorPrototype).length); |
| 11 assertSame(1, Object.getOwnPropertySymbols(iteratorPrototype).length); |
| 12 assertSame(Symbol.iterator, |
| 13 Object.getOwnPropertySymbols(iteratorPrototype)[0]); |
| 14 |
| 15 var descr = Object.getOwnPropertyDescriptor(iteratorPrototype, Symbol.iterator); |
| 16 assertTrue(descr.configurable); |
| 17 assertFalse(descr.enumerable); |
| 18 assertTrue(descr.writable); |
| 19 |
| 20 var iteratorFunction = descr.value; |
| 21 assertSame('function', typeof iteratorFunction); |
| 22 assertSame(0, iteratorFunction.length); |
| 23 assertSame('[Symbol.iterator]', iteratorFunction.name); |
| 24 |
| 25 var obj = {}; |
| 26 assertSame(obj, iteratorFunction.call(obj)); |
| 27 assertSame(iteratorPrototype, iteratorPrototype[Symbol.iterator]()); |
| 28 |
| 29 var mapIteratorPrototype = new Map().entries().__proto__; |
| 30 var setIteratorPrototype = new Set().values().__proto__; |
| 31 var stringIteratorPrototype = 'abc'[Symbol.iterator]().__proto__; |
| 32 assertSame(iteratorPrototype, mapIteratorPrototype.__proto__); |
| 33 assertSame(iteratorPrototype, setIteratorPrototype.__proto__); |
| 34 assertSame(iteratorPrototype, stringIteratorPrototype.__proto__); |
| 35 |
| 36 var typedArrays = [ |
| 37 Float32Array, |
| 38 Float64Array, |
| 39 Int16Array, |
| 40 Int32Array, |
| 41 Int8Array, |
| 42 Uint16Array, |
| 43 Uint32Array, |
| 44 Uint8Array, |
| 45 Uint8ClampedArray, |
| 46 ]; |
| 47 |
| 48 for (var constructor of typedArrays) { |
| 49 var array = new constructor(); |
| 50 var iterator = array[Symbol.iterator](); |
| 51 assertSame(iteratorPrototype, iterator.__proto__.__proto__); |
| 52 } |
| 53 |
| 54 function* gen() {} |
| 55 assertSame(iteratorPrototype, gen.prototype.__proto__.__proto__); |
| 56 var g = gen(); |
| 57 assertSame(gen.prototype, g.__proto__); |
| 58 assertSame(iteratorPrototype, g.__proto__.__proto__.__proto__); |
OLD | NEW |