OLD | NEW |
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-arrow-functions --allow-natives-syntax | 5 // Flags: --harmony-arrow-functions --allow-natives-syntax |
6 // Flags: --harmony-spreadcalls | 6 // Flags: --harmony-spreadcalls |
7 | 7 |
8 (function TestSuperNamedLoads() { | 8 (function TestSuperNamedLoads() { |
9 function Base() { } | 9 function Base() { } |
10 function fBase() { } | 10 function fBase() { } |
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 let o = f(); | 2174 let o = f(); |
2175 assertEquals(2, o.x); | 2175 assertEquals(2, o.x); |
2176 assertInstanceof(o, Derived); | 2176 assertInstanceof(o, Derived); |
2177 | 2177 |
2178 assertThrows(function() { | 2178 assertThrows(function() { |
2179 f(); | 2179 f(); |
2180 }, ReferenceError); | 2180 }, ReferenceError); |
2181 })(); | 2181 })(); |
2182 | 2182 |
2183 | 2183 |
| 2184 (function TestSuperCallInLoop() { |
| 2185 'use strict'; |
| 2186 class Base { |
| 2187 constructor(x) { |
| 2188 this.x = x; |
| 2189 } |
| 2190 } |
| 2191 class Derived extends Base { |
| 2192 constructor(x, n) { |
| 2193 for (var i = 0; i < n; ++i) { |
| 2194 super(x); |
| 2195 } |
| 2196 } |
| 2197 } |
| 2198 |
| 2199 let o = new Derived(23, 1); |
| 2200 assertEquals(23, o.x); |
| 2201 assertInstanceof(o, Derived); |
| 2202 |
| 2203 assertThrows("new Derived(42, 0)", ReferenceError); |
| 2204 assertThrows("new Derived(65, 2)", ReferenceError); |
| 2205 })(); |
| 2206 |
| 2207 |
| 2208 (function TestSuperCallReentrant() { |
| 2209 'use strict'; |
| 2210 class Base { |
| 2211 constructor(fun) { |
| 2212 this.x = fun(); |
| 2213 } |
| 2214 } |
| 2215 class Derived extends Base { |
| 2216 constructor(x) { |
| 2217 let f = () => super(() => x) |
| 2218 super(f); |
| 2219 } |
| 2220 } |
| 2221 assertThrows("new Derived(23)", ReferenceError); |
| 2222 })(); |
| 2223 |
| 2224 |
2184 (function TestSuperCallSpreadInEval() { | 2225 (function TestSuperCallSpreadInEval() { |
2185 'use strict'; | 2226 'use strict'; |
2186 class Base { | 2227 class Base { |
2187 constructor(x) { | 2228 constructor(x) { |
2188 this.x = x; | 2229 this.x = x; |
2189 } | 2230 } |
2190 } | 2231 } |
2191 class Derived extends Base { | 2232 class Derived extends Base { |
2192 constructor(x) { | 2233 constructor(x) { |
2193 eval('super(...[x])'); | 2234 eval('super(...[x])'); |
(...skipping 12 matching lines...) Expand all Loading... |
2206 } | 2247 } |
2207 } | 2248 } |
2208 class Derived extends Base { | 2249 class Derived extends Base { |
2209 constructor(x) { | 2250 constructor(x) { |
2210 (() => super(...[x]))(); | 2251 (() => super(...[x]))(); |
2211 } | 2252 } |
2212 } | 2253 } |
2213 let d = new Derived(42); | 2254 let d = new Derived(42); |
2214 assertSame(42, d.x); | 2255 assertSame(42, d.x); |
2215 })(); | 2256 })(); |
OLD | NEW |