OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library factories_test; |
| 6 |
| 7 import 'test_base.dart'; |
| 8 |
| 9 class A<T> { |
| 10 factory A() { |
| 11 return new B<T>(); |
| 12 } |
| 13 |
| 14 factory A.named() { |
| 15 return new A<T>.internal(); |
| 16 } |
| 17 |
| 18 factory A.forward() = A<T>.internal; |
| 19 |
| 20 A.internal(); |
| 21 } |
| 22 |
| 23 class B<T> extends A<T> { |
| 24 B() : super.internal(); |
| 25 } |
| 26 |
| 27 class X {} |
| 28 |
| 29 class Y {} |
| 30 |
| 31 main() { |
| 32 expectTrue(new A<X>.named() is A<X>); |
| 33 expectTrue(new A<X>.named() is! A<Y>); |
| 34 expectTrue(new A<X>.forward() is A<X>); |
| 35 expectTrue(new A<X>.forward() is! A<Y>); |
| 36 expectTrue(new A<X>() is B<X>); |
| 37 expectTrue(new A<X>() is! B<Y>); |
| 38 expectTrue(new A<X>.named() is! B<X>); |
| 39 expectTrue(new A<X>.forward() is! B<X>); |
| 40 } |
OLD | NEW |