| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Dart test program for constructors without function bodies. | 4 // Dart test program for constructors without function bodies. |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; |
| 7 |
| 6 // Test a non-const constructor works without a body. | 8 // Test a non-const constructor works without a body. |
| 7 class First { | 9 class First { |
| 8 First(int this.value); | 10 First(int this.value); |
| 9 First.named(int this.value); | 11 First.named(int this.value); |
| 10 int value; | 12 int value; |
| 11 } | 13 } |
| 12 | 14 |
| 13 // Test a const constructor works without a body. | 15 // Test a const constructor works without a body. |
| 14 class Second { | 16 class Second { |
| 15 const Second(int this.value); | 17 const Second(int this.value); |
| 16 const Second.named(int this.value); | 18 const Second.named(int this.value); |
| 17 final int value; | 19 final int value; |
| 18 } | 20 } |
| 19 | 21 |
| 20 class ConstructorBodyTest { | 22 class ConstructorBodyTest { |
| 21 static testMain() { | 23 static testMain() { |
| 22 Expect.equals(4, new First(4).value); | 24 Expect.equals(4, new First(4).value); |
| 23 Expect.equals(5, new First.named(5).value); | 25 Expect.equals(5, new First.named(5).value); |
| 24 Expect.equals(6, new Second(6).value); | 26 Expect.equals(6, new Second(6).value); |
| 25 Expect.equals(7, new Second.named(7).value); | 27 Expect.equals(7, new Second.named(7).value); |
| 26 } | 28 } |
| 27 } | 29 } |
| 28 | 30 |
| 29 main() { | 31 main() { |
| 30 ConstructorBodyTest.testMain(); | 32 ConstructorBodyTest.testMain(); |
| 31 } | 33 } |
| OLD | NEW |