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

Side by Side Diff: tests/lib/mirrors/class_declarations_test.dart

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

Powered by Google App Engine
This is Rietveld 408576698