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 library test.reflected_type_test; | 5 library test.reflected_type_test; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 | 10 |
11 class A<T> {} | 11 class A<T> {} |
12 class B extends A {} | 12 class B extends A {} |
13 class C extends A<num, int> {} // /// 01: static type warning | 13 class C extends A<num, int> {} // //# 01: static type warning |
14 class D extends A<int> {} | 14 class D extends A<int> {} |
15 class E<S> extends A<S> {} | 15 class E<S> extends A<S> {} |
16 class F<R> extends A<int> {} | 16 class F<R> extends A<int> {} |
17 class G {} | 17 class G {} |
18 class H<A,B,C> {} | 18 class H<A,B,C> {} |
19 | 19 |
20 expectReflectedType(classMirror, expectedType) { | 20 expectReflectedType(classMirror, expectedType) { |
21 if (expectedType == null) { | 21 if (expectedType == null) { |
22 Expect.isFalse(classMirror.hasReflectedType, | 22 Expect.isFalse(classMirror.hasReflectedType, |
23 "$classMirror should not have a reflected type"); | 23 "$classMirror should not have a reflected type"); |
(...skipping 12 matching lines...) Expand all Loading... |
36 expectReflectedType(reflectClass(String), String); | 36 expectReflectedType(reflectClass(String), String); |
37 expectReflectedType(reflectClass(int), int); | 37 expectReflectedType(reflectClass(int), int); |
38 expectReflectedType(reflectClass(num), num); | 38 expectReflectedType(reflectClass(num), num); |
39 expectReflectedType(reflectClass(double), double); | 39 expectReflectedType(reflectClass(double), double); |
40 expectReflectedType(reflectClass(bool), bool); | 40 expectReflectedType(reflectClass(bool), bool); |
41 expectReflectedType(reflectClass(Null), Null); | 41 expectReflectedType(reflectClass(Null), Null); |
42 | 42 |
43 // Declarations. | 43 // Declarations. |
44 expectReflectedType(reflectClass(A), null); | 44 expectReflectedType(reflectClass(A), null); |
45 expectReflectedType(reflectClass(B), B); | 45 expectReflectedType(reflectClass(B), B); |
46 expectReflectedType(reflectClass(C), C); // /// 01: continued | 46 expectReflectedType(reflectClass(C), C); // //# 01: continued |
47 expectReflectedType(reflectClass(D), D); | 47 expectReflectedType(reflectClass(D), D); |
48 expectReflectedType(reflectClass(E), null); | 48 expectReflectedType(reflectClass(E), null); |
49 expectReflectedType(reflectClass(F), null); | 49 expectReflectedType(reflectClass(F), null); |
50 expectReflectedType(reflectClass(G), G); | 50 expectReflectedType(reflectClass(G), G); |
51 expectReflectedType(reflectClass(H), null); | 51 expectReflectedType(reflectClass(H), null); |
52 | 52 |
53 // Instantiations. | 53 // Instantiations. |
54 expectReflectedType(reflect(new A()).type, new A().runtimeType); | 54 expectReflectedType(reflect(new A()).type, new A().runtimeType); |
55 expectReflectedType(reflect(new B()).type, new B().runtimeType); | 55 expectReflectedType(reflect(new B()).type, new B().runtimeType); |
56 expectReflectedType(reflect(new C()).type, new C().runtimeType); // /// 01: co
ntinued | 56 expectReflectedType(reflect(new C()).type, new C().runtimeType); // //# 01: co
ntinued |
57 expectReflectedType(reflect(new D()).type, new D().runtimeType); | 57 expectReflectedType(reflect(new D()).type, new D().runtimeType); |
58 expectReflectedType(reflect(new E()).type, new E().runtimeType); | 58 expectReflectedType(reflect(new E()).type, new E().runtimeType); |
59 expectReflectedType(reflect(new F()).type, new F().runtimeType); | 59 expectReflectedType(reflect(new F()).type, new F().runtimeType); |
60 expectReflectedType(reflect(new G()).type, new G().runtimeType); | 60 expectReflectedType(reflect(new G()).type, new G().runtimeType); |
61 expectReflectedType(reflect(new H()).type, new H().runtimeType); | 61 expectReflectedType(reflect(new H()).type, new H().runtimeType); |
62 | 62 |
63 expectReflectedType(reflect(new A<num>()).type, new A<num>().runtimeType); | 63 expectReflectedType(reflect(new A<num>()).type, new A<num>().runtimeType); |
64 expectReflectedType(reflect(new B<num>()).type.superclass, // /// 02: static t
ype warning | 64 expectReflectedType(reflect(new B<num>()).type.superclass, // //# 02: static t
ype warning |
65 new A<dynamic>().runtimeType); // /// 02: continue
d | 65 new A<dynamic>().runtimeType); // //# 02: continue
d |
66 expectReflectedType(reflect(new C<num>()).type.superclass, // /// 01: continue
d | 66 expectReflectedType(reflect(new C<num>()).type.superclass, // //# 01: continue
d |
67 new A<dynamic>().runtimeType); // /// 01: continue
d | 67 new A<dynamic>().runtimeType); // //# 01: continue
d |
68 expectReflectedType(reflect(new D<num>()).type.superclass, // /// 03: static t
ype warning | 68 expectReflectedType(reflect(new D<num>()).type.superclass, // //# 03: static t
ype warning |
69 new A<int>().runtimeType); // /// 03: continue
d | 69 new A<int>().runtimeType); // //# 03: continue
d |
70 expectReflectedType(reflect(new E<num>()).type, new E<num>().runtimeType); | 70 expectReflectedType(reflect(new E<num>()).type, new E<num>().runtimeType); |
71 expectReflectedType(reflect(new E<num>()).type.superclass, | 71 expectReflectedType(reflect(new E<num>()).type.superclass, |
72 new A<num>().runtimeType); | 72 new A<num>().runtimeType); |
73 expectReflectedType(reflect(new F<num>()).type.superclass, | 73 expectReflectedType(reflect(new F<num>()).type.superclass, |
74 new A<int>().runtimeType); | 74 new A<int>().runtimeType); |
75 expectReflectedType(reflect(new F<num>()).type, new F<num>().runtimeType); | 75 expectReflectedType(reflect(new F<num>()).type, new F<num>().runtimeType); |
76 expectReflectedType(reflect(new H<num, num, num>()).type, | 76 expectReflectedType(reflect(new H<num, num, num>()).type, |
77 new H<num, num, num>().runtimeType); | 77 new H<num, num, num>().runtimeType); |
78 } | 78 } |
OLD | NEW |