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

Side by Side Diff: test/mjsunit/harmony/array-concat-object-proto-dict-getter.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
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Check that @@isConcatSpreadable is checked when set on Object.prototype
6 // with a dictionary backing store.
7
8 // Force Object.prototype into dictionary backing store by adding many
9 // properties.
10 for (var i = 0; i < 10*1000; i++) {
11 Object.prototype['generatedProperty'+i] = true;
12 }
13
14 var array = [1, 2, 3];
15 var object = {length: 1, '0': 'a'};
16
17 function testConcatDefaults() {
18 assertEquals(array, [].concat(array));
19 assertEquals(array, array.concat([]));
20 assertEquals([1, 2, 3, 1, 2, 3], array.concat(array));
21 assertEquals([object], [].concat(object));
22 assertEquals([1, 2, 3, object], array.concat(object));
23 assertEquals([object], Array.prototype.concat.call(object,[]));
24 assertEquals([object, 1, 2, 3], Array.prototype.concat.call(object, array));
25 assertEquals([object, object], Array.prototype.concat.call(object, object));
26 }
27
28 testConcatDefaults();
29
30 var concatSpreadable = false;
31 Object.defineProperty(Object.prototype, Symbol.isConcatSpreadable, {
32 get() { return concatSpreadable },
33 configurable: true
34 });
35
36 assertEquals([[], array], [].concat(array));
37 assertEquals([array, []], array.concat([]));
38 assertEquals([array, array], array.concat(array));
39 assertEquals([[], object], [].concat(object));
40 assertEquals([array, object], array.concat(object));
41 assertEquals([object, []], Array.prototype.concat.call(object,[]));
42 assertEquals([object, array], Array.prototype.concat.call(object, array));
43 assertEquals([object, object], Array.prototype.concat.call(object, object));
44
45 concatSpreadable = true;
46
47 assertEquals(array, [].concat(array));
48 assertEquals(array, array.concat([]));
49 assertEquals([1, 2, 3, 1, 2, 3], array.concat(array));
50 assertEquals(['a'], [].concat(object));
51 assertEquals([1, 2, 3, 'a'], array.concat(object));
52 assertEquals(['a'], Array.prototype.concat.call(object,[]));
53 assertEquals(['a', 1, 2, 3], Array.prototype.concat.call(object, array));
54 assertEquals(['a', 'a'], Array.prototype.concat.call(object, object));
55
56 delete Object.prototype[Symbol.isConcatSpreadable];
57 testConcatDefaults();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/array-concat-object-proto-dict.js ('k') | test/mjsunit/harmony/array-concat-object-proto-generic-dict.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698