OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library test.generic_mixin; | |
6 | |
7 import 'dart:mirrors'; | |
8 | |
9 import 'package:expect/expect.dart'; | |
10 | |
11 import 'generics_helper.dart'; | |
12 | |
13 class Super<S> {} | |
14 | |
15 class Mixin<M> {} | |
16 | |
17 class Nixim<N> {} | |
18 | |
19 class NonGenericMixinApplication1 = Super with Mixin; | |
20 class NonGenericMixinApplication2 = Super<num> with Mixin<String>; | |
21 | |
22 class GenericMixinApplication1<MA> = Super<MA> with Mixin<MA>; | |
23 class GenericMixinApplication2<MA> = Super<num> with Mixin<String>; | |
24 | |
25 class NonGenericClass1 extends Super with Mixin {} | |
26 | |
27 class NonGenericClass2 extends Super<num> with Mixin<String> {} | |
28 | |
29 class GenericClass1<C> extends Super<C> with Mixin<C> {} | |
30 | |
31 class GenericClass2<C> extends Super<num> with Mixin<String> {} | |
32 | |
33 class GenericMultipleMixins<A, B, C> extends Super<A> with Mixin<B>, Nixim<C> {} | |
34 | |
35 main() { | |
36 TypeMirror dynamicMirror = currentMirrorSystem().dynamicType; | |
37 | |
38 typeParameters(reflectClass(NonGenericMixinApplication1).mixin, [#M]); | |
39 typeParameters(reflectClass(NonGenericMixinApplication2).mixin, [#M]); | |
40 typeParameters(reflectClass(GenericMixinApplication1).mixin, [#M]); | |
41 typeParameters(reflectClass(GenericMixinApplication2).mixin, [#M]); | |
42 typeParameters(reflectClass(NonGenericClass1).mixin, []); | |
43 typeParameters(reflectClass(NonGenericClass2).mixin, []); | |
44 typeParameters(reflectClass(GenericClass1).mixin, [#C]); | |
45 typeParameters(reflectClass(GenericClass2).mixin, [#C]); | |
46 typeParameters(reflectClass(NonGenericClass1).superclass.mixin, [#M]); | |
47 typeParameters(reflectClass(NonGenericClass2).superclass.mixin, [#M]); | |
48 typeParameters(reflectClass(GenericClass1).superclass.mixin, [#M]); | |
49 typeParameters(reflectClass(GenericClass2).superclass.mixin, [#M]); | |
50 typeParameters(reflectClass(GenericMultipleMixins).mixin, [#A, #B, #C]); | |
51 typeParameters(reflectClass(GenericMultipleMixins).superclass.mixin, [#N]); | |
52 typeParameters( | |
53 reflectClass(GenericMultipleMixins).superclass.superclass.mixin, [#M]); | |
54 typeParameters( | |
55 reflectClass(GenericMultipleMixins) | |
56 .superclass | |
57 .superclass | |
58 .superclass | |
59 .mixin, | |
60 [#S]); | |
61 | |
62 typeArguments( | |
63 reflectClass(NonGenericMixinApplication1).mixin, [dynamicMirror]); | |
64 typeArguments( | |
65 reflectClass(NonGenericMixinApplication2).mixin, [reflectClass(String)]); | |
66 typeArguments(reflectClass(GenericMixinApplication1).mixin, | |
67 [reflectClass(GenericMixinApplication1).typeVariables.single]); | |
68 typeArguments( | |
69 reflectClass(GenericMixinApplication2).mixin, [reflectClass(String)]); | |
70 typeArguments(reflectClass(NonGenericClass1).mixin, []); | |
71 typeArguments(reflectClass(NonGenericClass2).mixin, []); | |
72 typeArguments(reflectClass(GenericClass1).mixin, []); | |
73 typeArguments(reflectClass(GenericClass2).mixin, []); | |
74 typeArguments( | |
75 reflectClass(NonGenericClass1).superclass.mixin, [dynamicMirror]); | |
76 typeArguments( | |
77 reflectClass(NonGenericClass2).superclass.mixin, [reflectClass(String)]); | |
78 typeArguments(reflectClass(GenericClass1).superclass.mixin, | |
79 [reflectClass(GenericClass1).typeVariables.single]); | |
80 typeArguments( | |
81 reflectClass(GenericClass2).superclass.mixin, [reflectClass(String)]); | |
82 typeArguments(reflectClass(GenericMultipleMixins).mixin, []); | |
83 typeArguments(reflectClass(GenericMultipleMixins).superclass.mixin, | |
84 [reflectClass(GenericMultipleMixins).typeVariables[2]]); | |
85 typeArguments(reflectClass(GenericMultipleMixins).superclass.superclass.mixin, | |
86 [reflectClass(GenericMultipleMixins).typeVariables[1]]); | |
87 typeArguments( | |
88 reflectClass(GenericMultipleMixins) | |
89 .superclass | |
90 .superclass | |
91 .superclass | |
92 .mixin, | |
93 [reflectClass(GenericMultipleMixins).typeVariables[0]]); | |
94 | |
95 typeParameters(reflect(new NonGenericMixinApplication1()).type.mixin, [#M]); | |
96 typeParameters(reflect(new NonGenericMixinApplication2()).type.mixin, [#M]); | |
97 typeParameters( | |
98 reflect(new GenericMixinApplication1<bool>()).type.mixin, [#M]); | |
99 typeParameters( | |
100 reflect(new GenericMixinApplication2<bool>()).type.mixin, [#M]); | |
101 typeParameters(reflect(new NonGenericClass1()).type.mixin, []); | |
102 typeParameters(reflect(new NonGenericClass2()).type.mixin, []); | |
103 typeParameters(reflect(new GenericClass1<bool>()).type.mixin, [#C]); | |
104 typeParameters(reflect(new GenericClass2<bool>()).type.mixin, [#C]); | |
105 typeParameters(reflect(new NonGenericClass1()).type.superclass.mixin, [#M]); | |
106 typeParameters(reflect(new NonGenericClass2()).type.superclass.mixin, [#M]); | |
107 typeParameters( | |
108 reflect(new GenericClass1<bool>()).type.superclass.mixin, [#M]); | |
109 typeParameters( | |
110 reflect(new GenericClass2<bool>()).type.superclass.mixin, [#M]); | |
111 typeParameters( | |
112 reflect(new GenericMultipleMixins<bool, String, int>()).type.mixin, | |
113 [#A, #B, #C]); | |
114 typeParameters( | |
115 reflect(new GenericMultipleMixins<bool, String, int>()) | |
116 .type | |
117 .superclass | |
118 .mixin, | |
119 [#N]); | |
120 typeParameters( | |
121 reflect(new GenericMultipleMixins<bool, String, int>()) | |
122 .type | |
123 .superclass | |
124 .superclass | |
125 .mixin, | |
126 [#M]); | |
127 typeParameters( | |
128 reflect(new GenericMultipleMixins<bool, String, int>()) | |
129 .type | |
130 .superclass | |
131 .superclass | |
132 .superclass | |
133 .mixin, | |
134 [#S]); | |
135 | |
136 typeArguments( | |
137 reflect(new NonGenericMixinApplication1()).type.mixin, [dynamicMirror]); | |
138 typeArguments(reflect(new NonGenericMixinApplication2()).type.mixin, | |
139 [reflectClass(String)]); | |
140 typeArguments(reflect(new GenericMixinApplication1<bool>()).type.mixin, | |
141 [reflectClass(bool)]); | |
142 typeArguments(reflect(new GenericMixinApplication2<bool>()).type.mixin, | |
143 [reflectClass(String)]); | |
144 typeArguments(reflect(new NonGenericClass1()).type.mixin, []); | |
145 typeArguments(reflect(new NonGenericClass2()).type.mixin, []); | |
146 typeArguments( | |
147 reflect(new GenericClass1<bool>()).type.mixin, [reflectClass(bool)]); | |
148 typeArguments( | |
149 reflect(new GenericClass2<bool>()).type.mixin, [reflectClass(bool)]); | |
150 typeArguments( | |
151 reflect(new NonGenericClass1()).type.superclass.mixin, [dynamicMirror]); | |
152 typeArguments(reflect(new NonGenericClass2()).type.superclass.mixin, | |
153 [reflectClass(String)]); | |
154 typeArguments(reflect(new GenericClass1<bool>()).type.superclass.mixin, | |
155 [reflectClass(bool)]); | |
156 typeArguments(reflect(new GenericClass2<bool>()).type.superclass.mixin, | |
157 [reflectClass(String)]); | |
158 typeArguments( | |
159 reflect(new GenericMultipleMixins<bool, String, int>()).type.mixin, | |
160 [reflectClass(bool), reflectClass(String), reflectClass(int)]); | |
161 typeArguments( | |
162 reflect(new GenericMultipleMixins<bool, String, int>()) | |
163 .type | |
164 .superclass | |
165 .mixin, | |
166 [reflectClass(int)]); | |
167 typeArguments( | |
168 reflect(new GenericMultipleMixins<bool, String, int>()) | |
169 .type | |
170 .superclass | |
171 .superclass | |
172 .mixin, | |
173 [reflectClass(String)]); | |
174 typeArguments( | |
175 reflect(new GenericMultipleMixins<bool, String, int>()) | |
176 .type | |
177 .superclass | |
178 .superclass | |
179 .superclass | |
180 .mixin, | |
181 [reflectClass(bool)]); | |
182 } | |
OLD | NEW |