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"; |
| 6 |
5 // Dart test program for testing default factories. | 7 // Dart test program for testing default factories. |
6 | 8 |
7 abstract class Vehicle { | 9 abstract class Vehicle { |
8 factory Vehicle() = GoogleOne.Vehicle; | 10 factory Vehicle() = GoogleOne.Vehicle; |
9 } | 11 } |
10 | 12 |
11 | 13 |
12 class Bike implements Vehicle, GoogleOne { | 14 class Bike implements Vehicle, GoogleOne { |
13 Bike.redOne() {} | 15 Bike.redOne() {} |
14 } | 16 } |
15 | 17 |
16 | 18 |
17 abstract class SpaceShip { | 19 abstract class SpaceShip { |
18 factory SpaceShip() = GoogleOne; | 20 factory SpaceShip() = GoogleOne; |
19 } | 21 } |
20 | 22 |
21 | 23 |
22 class GoogleOne implements SpaceShip { | 24 class GoogleOne implements SpaceShip { |
23 GoogleOne.internal_() {} | 25 GoogleOne.internal_() {} |
24 factory GoogleOne() { return new GoogleOne.internal_(); } | 26 factory GoogleOne() { return new GoogleOne.internal_(); } |
25 factory GoogleOne.Vehicle() { return new Bike.redOne(); } | 27 factory GoogleOne.Vehicle() { return new Bike.redOne(); } |
26 } | 28 } |
27 | 29 |
28 | 30 |
29 main() { | 31 main() { |
30 Expect.equals(true, (new Bike.redOne()) is Bike); | 32 Expect.equals(true, (new Bike.redOne()) is Bike); |
31 Expect.equals(true, (new SpaceShip()) is GoogleOne); | 33 Expect.equals(true, (new SpaceShip()) is GoogleOne); |
32 Expect.equals(true, (new Vehicle()) is Bike); | 34 Expect.equals(true, (new Vehicle()) is Bike); |
33 } | 35 } |
OLD | NEW |