OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Tests self referencing types. | 5 // Tests self referencing types. |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 class Base<U, V> { | 9 class Base<U, V> { |
10 get u => U; | 10 get u => U; |
11 get v => V; | 11 get v => V; |
12 } | 12 } |
13 | 13 |
14 class Derived1<U, V> extends Base<Derived1<U, V>, | 14 class Derived1<U, V> |
15 Derived1<Derived2<V, U>, Derived2>> {} | 15 extends Base<Derived1<U, V>, Derived1<Derived2<V, U>, Derived2>> {} |
16 | 16 |
17 class Derived2<U, V> extends Base<Derived2<U, V>, | 17 class Derived2<U, V> |
18 Derived2<Derived1<V, U>, Derived1>> {} | 18 extends Base<Derived2<U, V>, Derived2<Derived1<V, U>, Derived1>> {} |
19 | 19 |
20 main() { | 20 main() { |
21 var d = new Derived1<Derived1, Derived2>(); | 21 var d = new Derived1<Derived1, Derived2>(); |
22 Expect.equals("Derived1<Derived1, Derived2>", d.u.toString()); | 22 Expect.equals("Derived1<Derived1, Derived2>", d.u.toString()); |
23 Expect.equals("Derived1<Derived2<Derived2, Derived1>, Derived2>", | 23 Expect.equals( |
24 d.v.toString()); | 24 "Derived1<Derived2<Derived2, Derived1>, Derived2>", d.v.toString()); |
25 Expect.isTrue(d is Derived1<Derived1, Derived2>); | 25 Expect.isTrue(d is Derived1<Derived1, Derived2>); |
26 Expect.isFalse(d is Derived1<Derived1, Derived1>); | 26 Expect.isFalse(d is Derived1<Derived1, Derived1>); |
27 Expect.isTrue(d is Base<Derived1<Derived1, Derived2>, | 27 Expect.isTrue(d is Base<Derived1<Derived1, Derived2>, |
28 Derived1<Derived2<Derived2, Derived1>, Derived2>>); | 28 Derived1<Derived2<Derived2, Derived1>, Derived2>>); |
29 Expect.isFalse(d is Base<Derived1<Derived1, Derived2>, | 29 Expect.isFalse(d is Base<Derived1<Derived1, Derived2>, |
30 Derived1<Derived2<Derived2, Derived2>, Derived2>>); | 30 Derived1<Derived2<Derived2, Derived2>, Derived2>>); |
31 } | 31 } |
OLD | NEW |