Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: test/codegen/lib/mirrors/class_declarations_test.dart

Issue 2265533002: Add mirrors tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.declarations_test;
6
7 import 'dart:mirrors';
8 import 'package:expect/expect.dart';
9
10 import 'stringify.dart';
11 import 'declarations_model.dart' as declarations_model;
12
13 Set<DeclarationMirror> inheritedDeclarations(ClassMirror cm) {
14 var decls = new Set<DeclarationMirror>();
15 while (cm != null) {
16 decls.addAll(cm.declarations.values);
17 cm = cm.superclass;
18 }
19 return decls;
20 }
21
22 main() {
23 ClassMirror cm = reflectClass(declarations_model.Class);
24
25 Expect.setEquals(
26 ['Variable(s(_instanceVariable) in s(Class), private)',
27 'Variable(s(_staticVariable) in s(Class), private, static)',
28 'Variable(s(instanceVariable) in s(Class))',
29 'Variable(s(staticVariable) in s(Class), static)'],
30 cm.declarations.values
31 .where((dm) => dm is VariableMirror).map(stringify),
32 'variables');
33
34 Expect.setEquals(
35 ['Method(s(_instanceGetter) in s(Class), private, getter)',
36 'Method(s(_staticGetter) in s(Class), private, static, getter)',
37 'Method(s(instanceGetter) in s(Class), getter)',
38 'Method(s(staticGetter) in s(Class), static, getter)'],
39 cm.declarations.values
40 .where((dm) => dm is MethodMirror && dm.isGetter).map(stringify),
41 'getters');
42
43 Expect.setEquals(
44 ['Method(s(_instanceSetter=) in s(Class), private, setter)',
45 'Method(s(_staticSetter=) in s(Class), private, static, setter)',
46 'Method(s(instanceSetter=) in s(Class), setter)',
47 'Method(s(staticSetter=) in s(Class), static, setter)'],
48 cm.declarations.values
49 .where((dm) => dm is MethodMirror && dm.isSetter).map(stringify),
50 'setters');
51
52 // dart2js stops testing here.
53 return; /// 01: ok
54
55 Expect.setEquals(
56 ['Method(s(+) in s(Class))',
57 'Method(s(_instanceMethod) in s(Class), private)',
58 'Method(s(_staticMethod) in s(Class), private, static)',
59 'Method(s(abstractMethod) in s(Class), abstract)',
60 'Method(s(instanceMethod) in s(Class))',
61 'Method(s(staticMethod) in s(Class), static)'],
62 cm.declarations.values
63 .where((dm) => dm is MethodMirror && dm.isRegularMethod).map(stringify),
64 'regular methods');
65
66 Expect.setEquals(
67 ['Method(s(Class._generativeConstructor) in s(Class), private, constructor)',
68 'Method(s(Class._normalFactory) in s(Class), private, static, constructor)',
69 'Method(s(Class._redirectingConstructor)'
70 ' in s(Class), private, constructor)',
71 'Method(s(Class._redirectingFactory)'
72 ' in s(Class), private, static, constructor)',
73 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
74 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
75 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
76 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)'],
77 cm.declarations.values
78 .where((dm) => dm is MethodMirror && dm.isConstructor).map(stringify),
79 'constructors and factories');
80
81 Expect.setEquals(
82 ['Method(s(Class._normalFactory) in s(Class), private, static, constructor)',
83 'Method(s(Class._redirectingFactory)'
84 ' in s(Class), private, static, constructor)',
85 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
86 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)',
87 'Method(s(_staticGetter) in s(Class), private, static, getter)',
88 'Method(s(_staticMethod) in s(Class), private, static)',
89 'Method(s(_staticSetter=) in s(Class), private, static, setter)',
90 'Variable(s(_staticVariable) in s(Class), private, static)',
91 'Method(s(staticGetter) in s(Class), static, getter)',
92 'Method(s(staticMethod) in s(Class), static)',
93 'Method(s(staticSetter=) in s(Class), static, setter)',
94 'Variable(s(staticVariable) in s(Class), static)'],
95 cm.declarations.values.where((dm) => dm.isStatic).map(stringify),
96 'statics');
97
98 Expect.setEquals(
99 ['Method(s(+) in s(Class))',
100 'TypeVariable(s(C) in s(Class),'
101 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
102 'Method(s(Class._generativeConstructor) in s(Class), private, constructor)',
103 'Method(s(Class._redirectingConstructor)'
104 ' in s(Class), private, constructor)',
105 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
106 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
107 'Method(s(_instanceGetter) in s(Class), private, getter)',
108 'Method(s(_instanceMethod) in s(Class), private)',
109 'Method(s(_instanceSetter=) in s(Class), private, setter)',
110 'Variable(s(_instanceVariable) in s(Class), private)',
111 'Method(s(abstractMethod) in s(Class), abstract)',
112 'Method(s(instanceGetter) in s(Class), getter)',
113 'Method(s(instanceMethod) in s(Class))',
114 'Method(s(instanceSetter=) in s(Class), setter)',
115 'Variable(s(instanceVariable) in s(Class))'],
116 cm.declarations.values.where((dm) => !dm.isStatic).map(stringify),
117 'non-statics');
118
119 Expect.setEquals(
120 ['Method(s(+) in s(Class))',
121 'TypeVariable(s(C) in s(Class),'
122 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
123 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
124 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
125 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
126 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)',
127 'Method(s(abstractMethod) in s(Class), abstract)',
128 'Method(s(instanceGetter) in s(Class), getter)',
129 'Method(s(instanceMethod) in s(Class))',
130 'Method(s(instanceSetter=) in s(Class), setter)',
131 'Variable(s(instanceVariable) in s(Class))',
132 'Method(s(staticGetter) in s(Class), static, getter)',
133 'Method(s(staticMethod) in s(Class), static)',
134 'Method(s(staticSetter=) in s(Class), static, setter)',
135 'Variable(s(staticVariable) in s(Class), static)'],
136 cm.declarations.values.where((dm) => !dm.isPrivate).map(stringify),
137 'public');
138
139 Expect.setEquals(
140 ['Method(s(*) in s(Mixin))',
141 'Method(s(+) in s(Class))',
142 'Method(s(-) in s(Superclass))',
143 'Method(s(==) in s(Object))',
144 'TypeVariable(s(C) in s(Class),'
145 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
146 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
147 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
148 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
149 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)',
150 'Method(s(Object) in s(Object), constructor)',
151 'TypeVariable(s(S) in s(Superclass),'
152 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
153 'Method(s(Superclass.inheritedGenerativeConstructor)'
154 ' in s(Superclass), constructor)',
155 'Method(s(Superclass.inheritedNormalFactory)'
156 ' in s(Superclass), static, constructor)',
157 'Method(s(Superclass.inheritedRedirectingConstructor)'
158 ' in s(Superclass), constructor)',
159 'Method(s(Superclass.inheritedRedirectingFactory)'
160 ' in s(Superclass), static, constructor)',
161 'Method(s(abstractMethod) in s(Class), abstract)',
162 'Method(s(hashCode) in s(Object), getter)',
163 'Method(s(inheritedInstanceGetter) in s(Superclass), getter)',
164 'Method(s(inheritedInstanceMethod) in s(Superclass))',
165 'Method(s(inheritedInstanceSetter=) in s(Superclass), setter)',
166 'Variable(s(inheritedInstanceVariable) in s(Superclass))',
167 'Method(s(inheritedStaticGetter) in s(Superclass), static, getter)',
168 'Method(s(inheritedStaticMethod) in s(Superclass), static)',
169 'Method(s(inheritedStaticSetter=) in s(Superclass), static, setter)',
170 'Variable(s(inheritedStaticVariable) in s(Superclass), static)',
171 'Method(s(instanceGetter) in s(Class), getter)',
172 'Method(s(instanceMethod) in s(Class))',
173 'Method(s(instanceSetter=) in s(Class), setter)',
174 'Variable(s(instanceVariable) in s(Class))',
175 'Method(s(mixinInstanceGetter) in s(Mixin), getter)',
176 'Method(s(mixinInstanceMethod) in s(Mixin))',
177 'Method(s(mixinInstanceSetter=) in s(Mixin), setter)',
178 'Variable(s(mixinInstanceVariable) in s(Mixin))',
179 'Method(s(noSuchMethod) in s(Object))',
180 'Method(s(runtimeType) in s(Object), getter)',
181 'Method(s(staticGetter) in s(Class), static, getter)',
182 'Method(s(staticMethod) in s(Class), static)',
183 'Method(s(staticSetter=) in s(Class), static, setter)',
184 'Variable(s(staticVariable) in s(Class), static)',
185 'Method(s(test.declarations_model.Superclass'
186 ' with test.declarations_model.Mixin.inheritedGenerativeConstructor)'
187 ' in s(test.declarations_model.Superclass'
188 ' with test.declarations_model.Mixin), constructor)',
189 'Method(s(test.declarations_model.Superclass'
190 ' with test.declarations_model.Mixin.inheritedRedirectingConstructor)'
191 ' in s(test.declarations_model.Superclass'
192 ' with test.declarations_model.Mixin), constructor)',
193 'Method(s(toString) in s(Object))',
194 'Variable(s(mixinStaticVariable) in s(Mixin), static)',
195 'Method(s(mixinStaticGetter) in s(Mixin), static, getter)',
196 'Method(s(mixinStaticSetter=) in s(Mixin), static, setter)',
197 'Method(s(mixinStaticMethod) in s(Mixin), static)'],
198 inheritedDeclarations(cm).where((dm) => !dm.isPrivate).map(stringify),
199 'transitive public');
200 // The public members of Object should be the same in all implementations, so
201 // we don't exclude Object here.
202
203 Expect.setEquals(
204 ['Method(s(+) in s(Class))',
205 'TypeVariable(s(C) in s(Class),'
206 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
207 'Method(s(Class._generativeConstructor) in s(Class), private, constructor)',
208 'Method(s(Class._normalFactory) in s(Class), private, static, constructor)',
209 'Method(s(Class._redirectingConstructor)'
210 ' in s(Class), private, constructor)',
211 'Method(s(Class._redirectingFactory)'
212 ' in s(Class), private, static, constructor)',
213 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
214 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
215 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
216 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)',
217 'Method(s(_instanceGetter) in s(Class), private, getter)',
218 'Method(s(_instanceMethod) in s(Class), private)',
219 'Method(s(_instanceSetter=) in s(Class), private, setter)',
220 'Variable(s(_instanceVariable) in s(Class), private)',
221 'Method(s(_staticGetter) in s(Class), private, static, getter)',
222 'Method(s(_staticMethod) in s(Class), private, static)',
223 'Method(s(_staticSetter=) in s(Class), private, static, setter)',
224 'Variable(s(_staticVariable) in s(Class), private, static)',
225 'Method(s(abstractMethod) in s(Class), abstract)',
226 'Method(s(instanceGetter) in s(Class), getter)',
227 'Method(s(instanceMethod) in s(Class))',
228 'Method(s(instanceSetter=) in s(Class), setter)',
229 'Variable(s(instanceVariable) in s(Class))',
230 'Method(s(staticGetter) in s(Class), static, getter)',
231 'Method(s(staticMethod) in s(Class), static)',
232 'Method(s(staticSetter=) in s(Class), static, setter)',
233 'Variable(s(staticVariable) in s(Class), static)'],
234 cm.declarations.values.map(stringify),
235 'declarations');
236
237 Expect.setEquals(
238 ['Method(s(*) in s(Mixin))',
239 'Method(s(+) in s(Class))',
240 'Method(s(-) in s(Superclass))',
241 'TypeVariable(s(C) in s(Class),'
242 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
243 'Method(s(Class._generativeConstructor) in s(Class), private, constructor)',
244 'Method(s(Class._normalFactory) in s(Class), private, static, constructor)',
245 'Method(s(Class._redirectingConstructor)'
246 ' in s(Class), private, constructor)',
247 'Method(s(Class._redirectingFactory)'
248 ' in s(Class), private, static, constructor)',
249 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
250 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
251 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
252 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)',
253 'TypeVariable(s(S) in s(Superclass),'
254 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
255 'Method(s(Superclass._inheritedGenerativeConstructor)'
256 ' in s(Superclass), private, constructor)',
257 'Method(s(Superclass._inheritedNormalFactory)'
258 ' in s(Superclass), private, static, constructor)',
259 'Method(s(Superclass._inheritedRedirectingConstructor)'
260 ' in s(Superclass), private, constructor)',
261 'Method(s(Superclass._inheritedRedirectingFactory)'
262 ' in s(Superclass), private, static, constructor)',
263 'Method(s(Superclass.inheritedGenerativeConstructor)'
264 ' in s(Superclass), constructor)',
265 'Method(s(Superclass.inheritedNormalFactory)'
266 ' in s(Superclass), static, constructor)',
267 'Method(s(Superclass.inheritedRedirectingConstructor)'
268 ' in s(Superclass), constructor)',
269 'Method(s(Superclass.inheritedRedirectingFactory)'
270 ' in s(Superclass), static, constructor)',
271 'Method(s(_inheritedInstanceGetter) in s(Superclass), private, getter)',
272 'Method(s(_inheritedInstanceMethod) in s(Superclass), private)',
273 'Method(s(_inheritedInstanceSetter=) in s(Superclass), private, setter)',
274 'Variable(s(_inheritedInstanceVariable) in s(Superclass), private)',
275 'Method(s(_inheritedStaticGetter)'
276 ' in s(Superclass), private, static, getter)',
277 'Method(s(_inheritedStaticMethod) in s(Superclass), private, static)',
278 'Method(s(_inheritedStaticSetter=)'
279 ' in s(Superclass), private, static, setter)',
280 'Variable(s(_inheritedStaticVariable) in s(Superclass), private, static)',
281 'Method(s(_instanceGetter) in s(Class), private, getter)',
282 'Method(s(_instanceMethod) in s(Class), private)',
283 'Method(s(_instanceSetter=) in s(Class), private, setter)',
284 'Variable(s(_instanceVariable) in s(Class), private)',
285 'Method(s(_mixinInstanceGetter) in s(Mixin), private, getter)',
286 'Method(s(_mixinInstanceMethod) in s(Mixin), private)',
287 'Method(s(_mixinInstanceSetter=) in s(Mixin), private, setter)',
288 'Variable(s(_mixinInstanceVariable) in s(Mixin), private)',
289 'Method(s(_staticGetter) in s(Class), private, static, getter)',
290 'Method(s(_staticMethod) in s(Class), private, static)',
291 'Method(s(_staticSetter=) in s(Class), private, static, setter)',
292 'Variable(s(_staticVariable) in s(Class), private, static)',
293 'Method(s(abstractMethod) in s(Class), abstract)',
294 'Method(s(inheritedInstanceGetter) in s(Superclass), getter)',
295 'Method(s(inheritedInstanceMethod) in s(Superclass))',
296 'Method(s(inheritedInstanceSetter=) in s(Superclass), setter)',
297 'Variable(s(inheritedInstanceVariable) in s(Superclass))',
298 'Method(s(inheritedStaticGetter) in s(Superclass), static, getter)',
299 'Method(s(inheritedStaticMethod) in s(Superclass), static)',
300 'Method(s(inheritedStaticSetter=) in s(Superclass), static, setter)',
301 'Variable(s(inheritedStaticVariable) in s(Superclass), static)',
302 'Method(s(instanceGetter) in s(Class), getter)',
303 'Method(s(instanceMethod) in s(Class))',
304 'Method(s(instanceSetter=) in s(Class), setter)',
305 'Variable(s(instanceVariable) in s(Class))',
306 'Method(s(mixinInstanceGetter) in s(Mixin), getter)',
307 'Method(s(mixinInstanceMethod) in s(Mixin))',
308 'Method(s(mixinInstanceSetter=) in s(Mixin), setter)',
309 'Variable(s(mixinInstanceVariable) in s(Mixin))',
310 'Method(s(staticGetter) in s(Class), static, getter)',
311 'Method(s(staticMethod) in s(Class), static)',
312 'Method(s(staticSetter=) in s(Class), static, setter)',
313 'Variable(s(staticVariable) in s(Class), static)',
314 'Method(s(test.declarations_model.Superclass'
315 ' with test.declarations_model.Mixin._inheritedGenerativeConstructor)'
316 ' in s(test.declarations_model.Superclass'
317 ' with test.declarations_model.Mixin), private, constructor)',
318 'Method(s(test.declarations_model.Superclass'
319 ' with test.declarations_model.Mixin._inheritedRedirectingConstructor)'
320 ' in s(test.declarations_model.Superclass'
321 ' with test.declarations_model.Mixin), private, constructor)',
322 'Method(s(test.declarations_model.Superclass'
323 ' with test.declarations_model.Mixin.inheritedGenerativeConstructor)'
324 ' in s(test.declarations_model.Superclass'
325 ' with test.declarations_model.Mixin), constructor)',
326 'Method(s(test.declarations_model.Superclass'
327 ' with test.declarations_model.Mixin.inheritedRedirectingConstructor)'
328 ' in s(test.declarations_model.Superclass'
329 ' with test.declarations_model.Mixin), constructor)',
330 'Variable(s(mixinStaticVariable) in s(Mixin), static)',
331 'Variable(s(_mixinStaticVariable) in s(Mixin), private, static)',
332 'Method(s(mixinStaticGetter) in s(Mixin), static, getter)',
333 'Method(s(mixinStaticSetter=) in s(Mixin), static, setter)',
334 'Method(s(mixinStaticMethod) in s(Mixin), static)',
335 'Method(s(_mixinStaticGetter) in s(Mixin), private, static, getter)',
336 'Method(s(_mixinStaticSetter=) in s(Mixin), private, static, setter)',
337 'Method(s(_mixinStaticMethod) in s(Mixin), private, static)'],
338 inheritedDeclarations(cm)
339 .difference(reflectClass(Object).declarations.values.toSet())
340 .map(stringify),
341 'transitive less Object');
342 // The private members of Object may vary across implementations, so we
343 // exclude the declarations of Object in this test case.
344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698