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

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

Issue 1409123003: [runtime] Avoid @@isConcatSpreadable lookup for fast path Array.prototype.concat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: merging with master Created 4 years, 7 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
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/mjsunit/harmony/array-concat-array-proto.js » ('j') | 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
5 (function testArrayConcatArity() { 4 (function testArrayConcatArity() {
6 "use strict"; 5 "use strict";
7 assertEquals(1, Array.prototype.concat.length); 6 assertEquals(1, Array.prototype.concat.length);
8 })(); 7 })();
9 8
10 9
11 (function testArrayConcatNoPrototype() { 10 (function testArrayConcatNoPrototype() {
12 "use strict"; 11 "use strict";
13 assertEquals(void 0, Array.prototype.concat.prototype); 12 assertEquals(void 0, Array.prototype.concat.prototype);
14 })(); 13 })();
15 14
16 15
17 (function testArrayConcatDescriptor() { 16 (function testArrayConcatDescriptor() {
18 "use strict"; 17 "use strict";
19 var desc = Object.getOwnPropertyDescriptor(Array.prototype, 'concat'); 18 var desc = Object.getOwnPropertyDescriptor(Array.prototype, 'concat');
20 assertEquals(false, desc.enumerable); 19 assertEquals(false, desc.enumerable);
21 })(); 20 })();
22 21
22 (function testNonConcatSpreadableArray() {
23 "use strict"
24 var array = [1, 2, 3];
25 assertEquals(array, [].concat(array));
26 assertEquals(array, array.concat([]));
27 array[Symbol.isConcatSpreadable] = false;
28 assertEquals([[1,2,3]], [].concat(array));
29 assertEquals([[1,2,3]], array.concat([]));
30 })();
23 31
24 (function testConcatArrayLike() { 32 (function testConcatArrayLike() {
25 "use strict"; 33 "use strict";
26 var obj = { 34 var obj = {
27 "length": 6, 35 "length": 6,
28 "1": "A", 36 "1": "A",
29 "3": "B", 37 "3": "B",
30 "5": "C" 38 "5": "C"
31 }; 39 };
32 obj[Symbol.isConcatSpreadable] = true; 40 obj[Symbol.isConcatSpreadable] = true;
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 if (key === "length") return Symbol(); 865 if (key === "length") return Symbol();
858 if (key === "2") return "baz"; 866 if (key === "2") return "baz";
859 if (key === "3") return "bar"; 867 if (key === "3") return "bar";
860 }; 868 };
861 var target = []; 869 var target = [];
862 var obj = new Proxy(target, {get: getTrap, has: () => true}); 870 var obj = new Proxy(target, {get: getTrap, has: () => true});
863 871
864 assertThrows(() => [].concat(obj), TypeError); 872 assertThrows(() => [].concat(obj), TypeError);
865 assertThrows(() => Array.prototype.concat.apply(obj), TypeError); 873 assertThrows(() => Array.prototype.concat.apply(obj), TypeError);
866 })(); 874 })();
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/mjsunit/harmony/array-concat-array-proto.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698