Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: test/mjsunit/es6/iterator-prototype.js

Issue 1128233008: [es6] Iterators and generators should "extend" %IteratorPrototype% (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add missing files Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/es6/generators-runtime.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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__);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/generators-runtime.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698