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

Unified Diff: test/mjsunit/harmony/array-concat.js

Issue 1192153002: [es6] fix IsConcatSpreadable() algorithm in runtime-array.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « src/runtime/runtime-array.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/array-concat.js
diff --git a/test/mjsunit/harmony/array-concat.js b/test/mjsunit/harmony/array-concat.js
index c1ff92c8c3df03100571eafb0f91dd2ad1abbcec..b623a5cc114303a50a39f25e39bb40a6053e1459 100644
--- a/test/mjsunit/harmony/array-concat.js
+++ b/test/mjsunit/harmony/array-concat.js
@@ -194,6 +194,15 @@ assertThrows(function() {
(function testConcatArraySubclass() {
"use strict";
+ // If @@isConcatSpreadable is not used, the value of IsArray(O)
+ // is used to determine the spreadable property.
+ class A extends Array {}
+ var obj = [].concat(new A(1, 2, 3), new A(4, 5, 6), new A(7, 8, 9));
+ assertEquals(9, obj.length);
+ for (var i = 0; i < obj.length; ++i) {
+ assertEquals(i + 1, obj[i]);
+ }
+
// TODO(caitp): when concat is called on instances of classes which extend
// Array, they should:
//
@@ -203,6 +212,19 @@ assertThrows(function() {
})();
+(function testConcatArraySubclassOptOut() {
+ "use strict";
+ class A extends Array {
+ get [Symbol.isConcatSpreadable]() { return false; }
+ }
+ var obj = [].concat(new A(1, 2, 3), new A(4, 5, 6), new A(7, 8, 9));
+ assertEquals(3, obj.length);
+ assertEquals(3, obj[0].length);
+ assertEquals(3, obj[1].length);
+ assertEquals(3, obj[2].length);
+})();
+
+
(function testConcatNonArray() {
"use strict";
class NonArray {
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698