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

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

Issue 1804963002: [builtins] Fix Array.prototype.concat bug (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: polishing corner cases and making tests work Created 4 years, 9 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 unified diff | Download patch
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-proxies --harmony-reflect 5 // Flags: --harmony-proxies --harmony-reflect
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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 var defValue = ta[0]; 260 var defValue = ta[0];
261 var expected = new Array(4000); 261 var expected = new Array(4000);
262 expected[0] = defValue; 262 expected[0] = defValue;
263 263
264 Object.defineProperty(ta, "length", { value: 4000 }); 264 Object.defineProperty(ta, "length", { value: 4000 });
265 ta[Symbol.isConcatSpreadable] = true; 265 ta[Symbol.isConcatSpreadable] = true;
266 assertEquals(expected, [].concat(ta)); 266 assertEquals(expected, [].concat(ta));
267 } 267 }
268 268
269 (function testConcatSmallTypedArray() { 269 (function testConcatSmallTypedArray() {
270 var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; 270 var length = 1;
271 [ 271 testConcatTypedArray(Uint8Array, length, Math.pow(2, 8));
272 Uint8Array, 272 testConcatTypedArray(Uint16Array, length, Math.pow(2, 16));
273 Uint16Array, 273 testConcatTypedArray(Uint32Array, length, Math.pow(2, 32));
274 Uint32Array, 274 testConcatTypedArray(Float32Array, length, false);
275 Float32Array, 275 testConcatTypedArray(Float64Array, length, false);
276 Float64Array
277 ].forEach(function(ctor, i) {
278 testConcatTypedArray(ctor, 1, max[i]);
279 });
280 })(); 276 })();
281 277
282 278
283 (function testConcatLargeTypedArray() { 279 (function testConcatLargeTypedArray() {
284 var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; 280 var length = 4000;
285 [ 281 testConcatTypedArray(Uint8Array, length, Math.pow(2, 8));
286 Uint8Array, 282 testConcatTypedArray(Uint16Array, length, Math.pow(2, 16));
287 Uint16Array, 283 testConcatTypedArray(Uint32Array, length, Math.pow(2, 32));
288 Uint32Array, 284 testConcatTypedArray(Float32Array, length, false);
289 Float32Array, 285 testConcatTypedArray(Float64Array, length, false);
290 Float64Array
291 ].forEach(function(ctor, i) {
292 testConcatTypedArray(ctor, 4000, max[i]);
293 });
294 })(); 286 })();
295 287
296 288
297 (function testConcatStrictArguments() { 289 (function testConcatStrictArguments() {
298 var args = (function(a, b, c) { "use strict"; return arguments; })(1,2,3); 290 var args = (function(a, b, c) { "use strict"; return arguments; })(1,2,3);
299 args[Symbol.isConcatSpreadable] = true; 291 args[Symbol.isConcatSpreadable] = true;
300 assertEquals([1, 2, 3, 1, 2, 3], [].concat(args, args)); 292 assertEquals([1, 2, 3, 1, 2, 3], [].concat(args, args));
301 293
302 Object.defineProperty(args, "length", { value: 6 }); 294 Object.defineProperty(args, "length", { value: 6 });
303 assertEquals([1, 2, 3, void 0, void 0, void 0], [].concat(args)); 295 assertEquals([1, 2, 3, void 0, void 0, void 0], [].concat(args));
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 if (key === "length") return Symbol(); 859 if (key === "length") return Symbol();
868 if (key === "2") return "baz"; 860 if (key === "2") return "baz";
869 if (key === "3") return "bar"; 861 if (key === "3") return "bar";
870 }; 862 };
871 var target = []; 863 var target = [];
872 var obj = new Proxy(target, {get: getTrap, has: () => true}); 864 var obj = new Proxy(target, {get: getTrap, has: () => true});
873 865
874 assertThrows(() => [].concat(obj), TypeError); 866 assertThrows(() => [].concat(obj), TypeError);
875 assertThrows(() => Array.prototype.concat.apply(obj), TypeError); 867 assertThrows(() => Array.prototype.concat.apply(obj), TypeError);
876 })(); 868 })();
OLDNEW
« no previous file with comments | « test/mjsunit/array-concat.js ('k') | test/mjsunit/regress/regress-crbug-594574-concat-leak-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698