| 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: --experimental-classes --harmony-classes | 5 // Flags: --experimental-classes --harmony-classes |
| 6 | 6 |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 class Base { | 9 class Base { |
| 10 constructor() { | 10 constructor(a, b) { |
| 11 let o = new Object(); | 11 let o = new Object(); |
| 12 o.prp = 1; | 12 o.prp = a + b; |
| 13 return o; | 13 return o; |
| 14 } | 14 } |
| 15 } | 15 } |
| 16 | 16 |
| 17 class Subclass extends Base { | 17 class Subclass extends Base { |
| 18 constructor() { | 18 constructor(a, b) { |
| 19 var exn; |
| 19 try { | 20 try { |
| 20 this.prp1 = 3; | 21 this.prp1 = 3; |
| 21 } catch (e) { | 22 } catch (e) { |
| 22 // TODO(dslomov): actually test the exception once TDZ is implemented. | 23 exn = e; |
| 23 } | 24 } |
| 24 super(); | 25 assertTrue(exn instanceof ReferenceError); |
| 25 assertSame(1, this.prp); | 26 super(a, b); |
| 27 assertSame(a + b, this.prp); |
| 26 assertSame(undefined, this.prp1); | 28 assertSame(undefined, this.prp1); |
| 27 assertFalse(this.hasOwnProperty("prp1")); | 29 assertFalse(this.hasOwnProperty("prp1")); |
| 28 return this; | 30 return this; |
| 29 } | 31 } |
| 30 } | 32 } |
| 31 | 33 |
| 32 let s = new Subclass(); | 34 let b = new Base(1, 2); |
| 35 assertSame(3, b.prp); |
| 36 |
| 37 let s = new Subclass(2, -1); |
| 33 assertSame(1, s.prp); | 38 assertSame(1, s.prp); |
| 34 assertSame(undefined, s.prp1); | 39 assertSame(undefined, s.prp1); |
| 35 assertFalse(s.hasOwnProperty("prp1")); | 40 assertFalse(s.hasOwnProperty("prp1")); |
| OLD | NEW |