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

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

Issue 2465253011: Fastpath some spread-call desugaring. (Closed)
Patch Set: Handles double arrays too 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
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/CallRuntime.golden ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..de38f129cd0a39c029af5429371454b004e4dcb0 100644
--- a/test/mjsunit/es6/spread-call.js
+++ b/test/mjsunit/es6/spread-call.js
@@ -24,6 +24,13 @@
assertEquals(5, countArgs(...[1, 2, 3, 4, 5]));
assertEquals(6, countArgs(...[1, 2, 3, 4, 5, 6]));
+ assertEquals(1, countArgs(...[1.1]));
+ assertEquals(2, countArgs(...[1.1, 2.2]));
+ assertEquals(3, countArgs(...[1.1, 2.2, 3.3]));
+ assertEquals(4, countArgs(...[1.1, 2.2, 3.3, 4.4]));
+ assertEquals(5, countArgs(...[1.1, 2.2, 3.3, 4.4, 5.5]));
+ assertEquals(6, countArgs(...[1.1, 2.2, 3.3, 4.4, 5.5, 6.6]));
+
assertEquals(1, countArgs(...new Set([1])));
assertEquals(2, countArgs(...new Set([1, 2])));
assertEquals(3, countArgs(...new Set([1, 2, 3])));
@@ -346,6 +353,91 @@
assertEquals("ABXYC1C2DEBXYC1C2", log);
})();
+(function testArrayPrototypeHoleGetterModifiesIteratorPrototypeNext() {
+ function sum() {
+ var sum = arguments[0];
+ for (var i = 1; i < arguments.length; ++i) {
+ sum += arguments[i];
+ }
+ return sum;
+ }
+ var a = [1, 2];
+ a[3] = 4;
+ var called = 0;
+
+ Object.defineProperty(Array.prototype, 2, {
+ get: function() {
+ var ai = a[Symbol.iterator]();
+ var original_next = ai.__proto__["next"];
+ Object.defineProperty(ai.__proto__, "next", {
+ get: function() {
+ called++;
+ return original_next;
+ }
+ });
+ return 3;
+ },
+ configurable: true
+ });
+
+ assertEquals(10, sum(...a));
+ assertEquals(2, called);
+
+ Object.defineProperty(Array.prototype, 2, {});
+})();
+
+(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 +462,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);
+})();
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/CallRuntime.golden ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698