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-classes --harmony-arrow-functions --allow-natives-syntax | 5 // Flags: --harmony-classes --harmony-arrow-functions --allow-natives-syntax |
6 | 6 // Flags: --harmony-spreadcalls |
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 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 class Derived extends Base { | 2100 class Derived extends Base { |
2101 arrow() { | 2101 arrow() { |
2102 assertSame(super.x, (() => super.x)()); | 2102 assertSame(super.x, (() => super.x)()); |
2103 assertSame(super.m(), (() => super.m())()); | 2103 assertSame(super.m(), (() => super.m())()); |
2104 return (() => super.m())(); | 2104 return (() => super.m())(); |
2105 } | 2105 } |
2106 } | 2106 } |
2107 let d = new Derived(); | 2107 let d = new Derived(); |
2108 assertSame(1, d.arrow()); | 2108 assertSame(1, d.arrow()); |
2109 })(); | 2109 })(); |
| 2110 |
| 2111 |
| 2112 (function TestSuperCallInEval() { |
| 2113 'use strict'; |
| 2114 class Base { |
| 2115 constructor(x) { |
| 2116 this.x = x; |
| 2117 } |
| 2118 } |
| 2119 class Derived extends Base { |
| 2120 constructor(x) { |
| 2121 eval('super(x)'); |
| 2122 } |
| 2123 } |
| 2124 let d = new Derived(42); |
| 2125 assertSame(42, d.x); |
| 2126 })(); |
| 2127 |
| 2128 |
| 2129 (function TestSuperCallInArrow() { |
| 2130 'use strict'; |
| 2131 class Base { |
| 2132 constructor(x) { |
| 2133 this.x = x; |
| 2134 } |
| 2135 } |
| 2136 class Derived extends Base { |
| 2137 constructor(x) { |
| 2138 (() => super(x))(); |
| 2139 } |
| 2140 } |
| 2141 let d = new Derived(42); |
| 2142 assertSame(42, d.x); |
| 2143 })(); |
| 2144 |
| 2145 |
| 2146 (function TestSuperCallEscapes() { |
| 2147 'use strict'; |
| 2148 class Base { |
| 2149 constructor(x) { |
| 2150 this.x = x; |
| 2151 } |
| 2152 } |
| 2153 |
| 2154 let f; |
| 2155 class Derived extends Base { |
| 2156 constructor() { |
| 2157 f = () => super(2); |
| 2158 } |
| 2159 } |
| 2160 assertThrows(function() { |
| 2161 new Derived(); |
| 2162 }, ReferenceError); |
| 2163 |
| 2164 let o = f(); |
| 2165 assertEquals(2, o.x); |
| 2166 assertInstanceof(o, Derived); |
| 2167 |
| 2168 assertThrows(function() { |
| 2169 f(); |
| 2170 }, ReferenceError); |
| 2171 })(); |
| 2172 |
| 2173 |
| 2174 (function TestSuperCallSpreadInEval() { |
| 2175 'use strict'; |
| 2176 class Base { |
| 2177 constructor(x) { |
| 2178 this.x = x; |
| 2179 } |
| 2180 } |
| 2181 class Derived extends Base { |
| 2182 constructor(x) { |
| 2183 eval('super(...[x])'); |
| 2184 } |
| 2185 } |
| 2186 let d = new Derived(42); |
| 2187 assertSame(42, d.x); |
| 2188 })(); |
| 2189 |
| 2190 |
| 2191 (function TestSuperCallSpreadInArrow() { |
| 2192 'use strict'; |
| 2193 class Base { |
| 2194 constructor(x) { |
| 2195 this.x = x; |
| 2196 } |
| 2197 } |
| 2198 class Derived extends Base { |
| 2199 constructor(x) { |
| 2200 (() => super(...[x]))(); |
| 2201 } |
| 2202 } |
| 2203 let d = new Derived(42); |
| 2204 assertSame(42, d.x); |
| 2205 })(); |
OLD | NEW |