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

Unified Diff: test/mjsunit/es6/spread-call.js

Issue 2465253011: Fastpath some spread-call desugaring. (Closed)
Patch Set: Use functions for testing initial_* objects Created 4 years, 1 month 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
Index: test/mjsunit/es6/spread-call.js
diff --git a/test/mjsunit/es6/spread-call.js b/test/mjsunit/es6/spread-call.js
index 05e17741d6862886be52ea2abe502bb798716fe8..b806c7814194840d023ef9b84ce1c9e0cfdeddcc 100644
--- a/test/mjsunit/es6/spread-call.js
+++ b/test/mjsunit/es6/spread-call.js
@@ -346,6 +346,58 @@
assertEquals("ABXYC1C2DEBXYC1C2", log);
})();
+(function testArrayHasOtherPrototype() {
+ function countArgs() { return arguments.length; }
+ var a = [1, 2, 3];
+ var b = {};
+ Object.defineProperty(b, Symbol.iterator, {
+ value: function*() {
+ yield 4;
+ },
+ configurable: true
+ });
+
+ Object.setPrototypeOf(a, b);
+
+ assertEquals(1, countArgs(...a));
+})();
+
+(function testArrayIteratorPrototypeGetter() {
+ function countArgs() { return arguments.length; }
+ var a = [1, 2, 3];
+ var ai = a[Symbol.iterator]();
+ var called = 0;
+
+ var original_next = ai.__proto__["next"];
+
+ Object.defineProperty(ai.__proto__, "next", {
+ get: function() {
+ called++;
+ return original_next;
+ }
+ });
+
+ countArgs(...a);
+
+ // should be called 4 times; 3 for the values, 1 for the final
+ // {value: undefined, done: true} pair
+ assertEquals(4, called);
+})();
+
+(function testArrayIteratorPrototypeModified() {
+ function countArgs() { return arguments.length; }
+ var a = [1,2,3];
+ var ai = a[Symbol.iterator]();
+ Object.defineProperty(ai.__proto__, "next", {
+ value: function() {
+ return {value: undefined, done: true};
+ },
+ configurable: true
+ });
+
+ assertEquals(0, countArgs(...a));
+
+})();
(function testCustomArrayPrototypeIterator() {
var origIterator =
@@ -370,3 +422,29 @@
Object.defineProperty(Array.prototype, Symbol.iterator, origIterator);
})();
+
+(function testGetPropertyIteratorCalledExactlyOnce() {
+ function countArgs() { return arguments.length; }
+ var a = [1, 2, 3];
+ var called = 0;
+
+ Object.defineProperty(Array.prototype, Symbol.iterator, {
+ value: function*() {
+ yield 1;
+ yield 2;
+ },
+ configurable: true
+ });
+
+ var it = a[Symbol.iterator];
+ Object.defineProperty(a, Symbol.iterator, {
+ get: function() {
+ called++;
+ return it;
+ }
+ });
+
+ countArgs(...a);
+
+ assertEquals(1, called);
+})();

Powered by Google App Engine
This is Rietveld 408576698