OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-species | |
6 | |
7 // Test the ES2015 @@species feature | 5 // Test the ES2015 @@species feature |
8 | 6 |
9 'use strict'; | 7 'use strict'; |
10 | 8 |
11 // Subclasses of Array construct themselves under map, etc | 9 // Subclasses of Array construct themselves under map, etc |
12 | 10 |
13 class MyArray extends Array { } | 11 class MyArray extends Array { } |
14 | 12 |
15 assertEquals(MyArray, new MyArray().map(()=>{}).constructor); | 13 assertEquals(MyArray, new MyArray().map(()=>{}).constructor); |
16 assertEquals(MyArray, new MyArray().filter(()=>{}).constructor); | 14 assertEquals(MyArray, new MyArray().filter(()=>{}).constructor); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 assertArrayEquals([0], params); | 162 assertArrayEquals([0], params); |
165 | 163 |
166 // @@species constructor can be a Proxy, and the realm access doesn't | 164 // @@species constructor can be a Proxy, and the realm access doesn't |
167 // crash | 165 // crash |
168 | 166 |
169 class MyProxyArray extends Array { } | 167 class MyProxyArray extends Array { } |
170 let ProxyArray = new Proxy(MyProxyArray, {}); | 168 let ProxyArray = new Proxy(MyProxyArray, {}); |
171 MyProxyArray.constructor = ProxyArray; | 169 MyProxyArray.constructor = ProxyArray; |
172 | 170 |
173 assertEquals(MyProxyArray, new ProxyArray().map(()=>{}).constructor); | 171 assertEquals(MyProxyArray, new ProxyArray().map(()=>{}).constructor); |
OLD | NEW |