2012-12-03 20:51:15 +00:00
|
|
|
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
2011-10-05 06:22:36 +00:00
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2013-04-05 19:43:16 +00:00
|
|
|
import "package:expect/expect.dart";
|
|
|
|
|
2011-10-05 06:22:36 +00:00
|
|
|
// Dart test program for testing default factories.
|
|
|
|
|
2012-12-03 20:51:15 +00:00
|
|
|
abstract class Vehicle {
|
2014-02-14 11:59:12 +00:00
|
|
|
factory Vehicle() = GoogleOne.Vehicle; /// 01: static type warning
|
2011-10-05 06:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-03 20:51:15 +00:00
|
|
|
class Bike implements Vehicle, GoogleOne {
|
2011-10-05 06:22:36 +00:00
|
|
|
Bike.redOne() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-03 20:51:15 +00:00
|
|
|
abstract class SpaceShip {
|
|
|
|
factory SpaceShip() = GoogleOne;
|
2011-10-05 06:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class GoogleOne implements SpaceShip {
|
|
|
|
GoogleOne.internal_() {}
|
|
|
|
factory GoogleOne() { return new GoogleOne.internal_(); }
|
2012-12-03 20:51:15 +00:00
|
|
|
factory GoogleOne.Vehicle() { return new Bike.redOne(); }
|
2011-10-05 06:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
main() {
|
2012-12-03 20:51:15 +00:00
|
|
|
Expect.equals(true, (new Bike.redOne()) is Bike);
|
|
|
|
Expect.equals(true, (new SpaceShip()) is GoogleOne);
|
2014-02-14 11:59:12 +00:00
|
|
|
Expect.equals(true, (new Vehicle()) is Bike); /// 01: continued
|
2011-10-05 06:22:36 +00:00
|
|
|
}
|