OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 abstract class A { | 7 abstract class A { |
8 factory A(int x, int y) = B; | 8 factory A(int x, int y) = B; |
9 } | 9 } |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 factory B.X(int a, int b) { return new XImpl(a * 10, b * 10); } | 30 factory B.X(int a, int b) { return new XImpl(a * 10, b * 10); } |
31 } | 31 } |
32 | 32 |
33 main() { | 33 main() { |
34 var a = new A(1, 2); | 34 var a = new A(1, 2); |
35 // Check that constructor B is invoked and not factory B.A. | 35 // Check that constructor B is invoked and not factory B.A. |
36 Expect.equals(1, a.x); | 36 Expect.equals(1, a.x); |
37 Expect.equals(2, a.y); | 37 Expect.equals(2, a.y); |
38 | 38 |
39 var x = new X(11, 22); // /// 00: dynamic type error | 39 var x = new X(11, 22); // //# 00: dynamic type error |
40 // Check that factory is invoked. | 40 // Check that factory is invoked. |
41 Expect.equals(110, x.x); // /// 00: continued | 41 Expect.equals(110, x.x); // //# 00: continued |
42 Expect.equals(220, x.y); // /// 00: continued | 42 Expect.equals(220, x.y); // //# 00: continued |
43 } | 43 } |
OLD | NEW |