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

Side by Side Diff: test/mjsunit/harmony/array-concat.js

Issue 799803003: Fix ArrayConcat for JSValues/JSFunctions/JSRegExps with @@isConcatSpreadable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« src/runtime/runtime-array.cc ('K') | « src/runtime/runtime-strings.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-arrays --harmony-classes 5 // Flags: --harmony-arrays --harmony-classes
6 6
7 (function testArrayConcatArity() { 7 (function testArrayConcatArity() {
8 "use strict"; 8 "use strict";
9 assertEquals(1, Array.prototype.concat.length); 9 assertEquals(1, Array.prototype.concat.length);
10 })(); 10 })();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 298
299 (function testConcatHoleySloppyArguments() { 299 (function testConcatHoleySloppyArguments() {
300 var args = (function(a) { return arguments; })(1,2,3); 300 var args = (function(a) { return arguments; })(1,2,3);
301 delete args[1]; 301 delete args[1];
302 args[Symbol.isConcatSpreadable] = true; 302 args[Symbol.isConcatSpreadable] = true;
303 assertEquals([1, void 0, 3, 1, void 0, 3], [].concat(args, args)); 303 assertEquals([1, void 0, 3, 1, void 0, 3], [].concat(args, args));
304 })(); 304 })();
305 305
306 306
307 (function testConcatSpreadableStringPrototype() {
308 var str1 = new String("yuck\uD83D\uDCA9")
309 // String wrapper objects are not concat-spreadable by default
310 assertEquals([str1], [].concat(str1));
311
312 String.prototype[Symbol.isConcatSpreadable] = true;
313 // String wrapper objects may be concat-spreadable
314 assertEquals(["y", "u", "c", "k", "\uD83D", "\uDCA9"],
315 [].concat(new String("yuck\uD83D\uDCA9")));
316
317 // String values are never concat-spreadable
318 assertEquals(["yuck\uD83D\uDCA9"], [].concat("yuck\uD83D\uDCA9"));
319 delete String.prototype[Symbol.isConcatSpreadable];
320 })();
321
322
307 // ES5 tests 323 // ES5 tests
308 (function testArrayConcatES5() { 324 (function testArrayConcatES5() {
309 "use strict"; 325 "use strict";
310 var poses; 326 var poses;
311 var pos; 327 var pos;
312 328
313 poses = [140, 4000000000]; 329 poses = [140, 4000000000];
314 while (pos = poses.shift()) { 330 while (pos = poses.shift()) {
315 var a = new Array(pos); 331 var a = new Array(pos);
316 var array_proto = []; 332 var array_proto = [];
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 arr3.length = 10000; 524 arr3.length = 10000;
509 for (var i = 0; i < 100; i++) { 525 for (var i = 0; i < 100; i++) {
510 Object.defineProperty(arr3, i * i, {get: mkGetter(i)}); 526 Object.defineProperty(arr3, i * i, {get: mkGetter(i)});
511 expectedTrace[i] = i; 527 expectedTrace[i] = i;
512 expectedTrace[100 + i] = i; 528 expectedTrace[100 + i] = i;
513 } 529 }
514 var r4 = [0].concat(arr3, arr3); 530 var r4 = [0].concat(arr3, arr3);
515 assertEquals(1 + arr3.length * 2, r4.length); 531 assertEquals(1 + arr3.length * 2, r4.length);
516 assertEquals(expectedTrace, trace); 532 assertEquals(expectedTrace, trace);
517 })(); 533 })();
OLDNEW
« src/runtime/runtime-array.cc ('K') | « src/runtime/runtime-strings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698