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 --harmony-destructuring --harmony-rest-parameter
s |
7 | 7 |
8 (function TestSuperNamedLoads() { | 8 (function TestSuperNamedLoads() { |
9 function Base() { } | 9 function Base() { } |
10 function fBase() { } | 10 function fBase() { } |
11 Base.prototype = { | 11 Base.prototype = { |
12 f() { | 12 f() { |
13 return "Base " + this.toString(); | 13 return "Base " + this.toString(); |
14 }, | 14 }, |
15 x: 15, | 15 x: 15, |
16 toString() { | 16 toString() { |
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 assertSame(super.x, (() => super.x)()); | 2115 assertSame(super.x, (() => super.x)()); |
2116 assertSame(super.m(), (() => super.m())()); | 2116 assertSame(super.m(), (() => super.m())()); |
2117 return (() => super.m())(); | 2117 return (() => super.m())(); |
2118 } | 2118 } |
2119 } | 2119 } |
2120 let d = new Derived(); | 2120 let d = new Derived(); |
2121 assertSame(1, d.arrow()); | 2121 assertSame(1, d.arrow()); |
2122 })(); | 2122 })(); |
2123 | 2123 |
2124 | 2124 |
| 2125 (function TestSuperInOtherScopes() { |
| 2126 var p = {x: 99}; |
| 2127 var o0 = {__proto__: p, f() { return eval("'use strict'; super.x") }}; |
| 2128 assertEquals(p.x, o0.f()); |
| 2129 var o1 = {__proto__: p, f() { with ({}) return super.x }}; |
| 2130 assertEquals(p.x, o1.f()); |
| 2131 var o2 = {__proto__: p, f({a}) { return super.x }}; |
| 2132 assertEquals(p.x, o2.f({})); |
| 2133 var o3 = {__proto__: p, f(...a) { return super.x }}; |
| 2134 assertEquals(p.x, o3.f()); |
| 2135 var o4 = {__proto__: p, f() { 'use strict'; { let x; return super.x } }}; |
| 2136 assertEquals(p.x, o4.f()); |
| 2137 })(); |
| 2138 |
| 2139 |
2125 (function TestSuperCallInEval() { | 2140 (function TestSuperCallInEval() { |
2126 'use strict'; | 2141 'use strict'; |
2127 class Base { | 2142 class Base { |
2128 constructor(x) { | 2143 constructor(x) { |
2129 this.x = x; | 2144 this.x = x; |
2130 } | 2145 } |
2131 } | 2146 } |
2132 class Derived extends Base { | 2147 class Derived extends Base { |
2133 constructor(x) { | 2148 constructor(x) { |
2134 let r = eval('super(x)'); | 2149 let r = eval('super(x)'); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 } | 2269 } |
2255 class Derived extends Base { | 2270 class Derived extends Base { |
2256 constructor(x) { | 2271 constructor(x) { |
2257 let r = (() => super(...[x]))(); | 2272 let r = (() => super(...[x]))(); |
2258 assertEquals(this, r); | 2273 assertEquals(this, r); |
2259 } | 2274 } |
2260 } | 2275 } |
2261 let d = new Derived(42); | 2276 let d = new Derived(42); |
2262 assertSame(42, d.x); | 2277 assertSame(42, d.x); |
2263 })(); | 2278 })(); |
OLD | NEW |