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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/es6/generators-runtime.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/iterator-prototype.js
diff --git a/test/mjsunit/es6/iterator-prototype.js b/test/mjsunit/es6/iterator-prototype.js
new file mode 100644
index 0000000000000000000000000000000000000000..0b266e9897a7178823fa1ee68f9b0aea7d196910
--- /dev/null
+++ b/test/mjsunit/es6/iterator-prototype.js
@@ -0,0 +1,58 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var arrayIteratorPrototype = [].entries().__proto__;
+var iteratorPrototype = arrayIteratorPrototype.__proto__;
+
+assertSame(Object.prototype, Object.getPrototypeOf(iteratorPrototype));
+assertTrue(Object.isExtensible(iteratorPrototype));
+assertSame(0, Object.getOwnPropertyNames(iteratorPrototype).length);
+assertSame(1, Object.getOwnPropertySymbols(iteratorPrototype).length);
+assertSame(Symbol.iterator,
+ Object.getOwnPropertySymbols(iteratorPrototype)[0]);
+
+var descr = Object.getOwnPropertyDescriptor(iteratorPrototype, Symbol.iterator);
+assertTrue(descr.configurable);
+assertFalse(descr.enumerable);
+assertTrue(descr.writable);
+
+var iteratorFunction = descr.value;
+assertSame('function', typeof iteratorFunction);
+assertSame(0, iteratorFunction.length);
+assertSame('[Symbol.iterator]', iteratorFunction.name);
+
+var obj = {};
+assertSame(obj, iteratorFunction.call(obj));
+assertSame(iteratorPrototype, iteratorPrototype[Symbol.iterator]());
+
+var mapIteratorPrototype = new Map().entries().__proto__;
+var setIteratorPrototype = new Set().values().__proto__;
+var stringIteratorPrototype = 'abc'[Symbol.iterator]().__proto__;
+assertSame(iteratorPrototype, mapIteratorPrototype.__proto__);
+assertSame(iteratorPrototype, setIteratorPrototype.__proto__);
+assertSame(iteratorPrototype, stringIteratorPrototype.__proto__);
+
+var typedArrays = [
+ Float32Array,
+ Float64Array,
+ Int16Array,
+ Int32Array,
+ Int8Array,
+ Uint16Array,
+ Uint32Array,
+ Uint8Array,
+ Uint8ClampedArray,
+];
+
+for (var constructor of typedArrays) {
+ var array = new constructor();
+ var iterator = array[Symbol.iterator]();
+ assertSame(iteratorPrototype, iterator.__proto__.__proto__);
+}
+
+function* gen() {}
+assertSame(iteratorPrototype, gen.prototype.__proto__.__proto__);
+var g = gen();
+assertSame(gen.prototype, g.__proto__);
+assertSame(iteratorPrototype, g.__proto__.__proto__.__proto__);
« 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