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 | 5 // Flags: --harmony-classes |
6 | 6 |
7 | 7 |
8 (function TestSuperNamedLoads() { | 8 (function TestSuperNamedLoads() { |
9 function Base() { } | 9 function Base() { } |
10 function Derived() { | 10 function Derived() { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 }.toMethod(Derived.prototype); | 218 }.toMethod(Derived.prototype); |
219 var d = new Derived(); | 219 var d = new Derived(); |
220 d.mSloppy(); | 220 d.mSloppy(); |
221 assertEquals(undefined, d.x); | 221 assertEquals(undefined, d.x); |
222 var d1 = new Derived(); | 222 var d1 = new Derived(); |
223 assertThrows(function() { d.mStrict(); }, ReferenceError); | 223 assertThrows(function() { d.mStrict(); }, ReferenceError); |
224 assertEquals(undefined, d.x); | 224 assertEquals(undefined, d.x); |
225 }()); | 225 }()); |
226 | 226 |
227 | 227 |
228 (function TestCountOperations() { | |
229 function Base() {} | |
230 Base.prototype = { | |
231 constructor: Base, | |
232 get x() { | |
233 return this._x; | |
234 }, | |
235 set x(v) { | |
236 this._x = v; | |
237 }, | |
238 _x: 1 | |
239 }; | |
240 | |
241 function Derived() {} | |
242 Derived.__proto__ = Base; | |
243 Derived.prototype = { | |
244 __proto__: Base.prototype, | |
245 constructor: Derived, | |
246 _x: 2 | |
247 }; | |
248 | |
249 Derived.prototype.testCounts = function() { | |
250 assertEquals(2, this._x); | |
251 assertEquals(2, super.x); | |
252 super.x++; | |
arv (Not doing code reviews)
2014/09/29 14:50:29
Maybe wrap these in assertEquals to also assert th
Dmitry Lomov (no reviews)
2014/09/29 14:54:45
No, these count operations without use of return v
| |
253 assertEquals(3, super.x); | |
254 ++super.x; | |
255 assertEquals(4, super.x); | |
256 assertEquals(4, super.x++); | |
257 assertEquals(5, super.x); | |
258 assertEquals(6, ++super.x); | |
259 assertEquals(6, super.x); | |
260 assertEquals(6, this._x); | |
261 | |
262 super.x--; | |
263 assertEquals(5, super.x); | |
264 --super.x; | |
265 assertEquals(4, super.x); | |
266 assertEquals(4, super.x--); | |
267 assertEquals(3, super.x); | |
268 assertEquals(2, --super.x); | |
269 assertEquals(2, super.x); | |
270 assertEquals(2, this._x); | |
271 }.toMethod(Derived.prototype); | |
272 new Derived().testCounts(); | |
273 }()); | |
274 | |
275 | |
228 (function TestUnsupportedCases() { | 276 (function TestUnsupportedCases() { |
229 function f1(x) { return super[x]; } | 277 function f1(x) { return super[x]; } |
278 function f2(x) { super[x] = 5; } | |
230 var o = {} | 279 var o = {} |
231 assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError); | 280 assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError); |
232 function f2() { super.x++; } | 281 assertThrows(function(){f2.toMethod(o)(x);}, ReferenceError); |
233 assertThrows(function(){f2.toMethod(o)();}, ReferenceError); | |
234 }()); | 282 }()); |
OLD | NEW |