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

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

Issue 36023003: Add LibraryMirror.declarations and ClassMirror.declarations to the API and both implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/declarations_model.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 inheritedDeclarations(cm).where((dm) => !dm.isPrivate).map(stringify),
195 'transitive public');
196 // The public members of Object should be the same in all implementations, so
197 // we don't exclude Object here.
198
199 Expect.setEquals(
200 ['Method(s(+) in s(Class))',
201 'TypeVariable(s(C) in s(Class),'
202 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
203 'Method(s(Class._generativeConstructor) in s(Class), private, constructor)',
204 'Method(s(Class._normalFactory) in s(Class), private, static, constructor)',
205 'Method(s(Class._redirectingConstructor)'
206 ' in s(Class), private, constructor)',
207 'Method(s(Class._redirectingFactory)'
208 ' in s(Class), private, static, constructor)',
209 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
210 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
211 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
212 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)',
213 'Method(s(_instanceGetter) in s(Class), private, getter)',
214 'Method(s(_instanceMethod) in s(Class), private)',
215 'Method(s(_instanceSetter=) in s(Class), private, setter)',
216 'Variable(s(_instanceVariable) in s(Class), private)',
217 'Method(s(_staticGetter) in s(Class), private, static, getter)',
218 'Method(s(_staticMethod) in s(Class), private, static)',
219 'Method(s(_staticSetter=) in s(Class), private, static, setter)',
220 'Variable(s(_staticVariable) in s(Class), private, static)',
221 'Method(s(abstractMethod) in s(Class), abstract)',
222 'Method(s(instanceGetter) in s(Class), getter)',
223 'Method(s(instanceMethod) in s(Class))',
224 'Method(s(instanceSetter=) in s(Class), setter)',
225 'Variable(s(instanceVariable) in s(Class))',
226 'Method(s(staticGetter) in s(Class), static, getter)',
227 'Method(s(staticMethod) in s(Class), static)',
228 'Method(s(staticSetter=) in s(Class), static, setter)',
229 'Variable(s(staticVariable) in s(Class), static)'],
230 cm.declarations.values.map(stringify),
231 'declarations');
232
233 Expect.setEquals(
234 ['Method(s(*) in s(Mixin))',
235 'Method(s(+) in s(Class))',
236 'Method(s(-) in s(Superclass))',
237 'TypeVariable(s(C) in s(Class),'
238 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
239 'Method(s(Class._generativeConstructor) in s(Class), private, constructor)',
240 'Method(s(Class._normalFactory) in s(Class), private, static, constructor)',
241 'Method(s(Class._redirectingConstructor)'
242 ' in s(Class), private, constructor)',
243 'Method(s(Class._redirectingFactory)'
244 ' in s(Class), private, static, constructor)',
245 'Method(s(Class.generativeConstructor) in s(Class), constructor)',
246 'Method(s(Class.normalFactory) in s(Class), static, constructor)',
247 'Method(s(Class.redirectingConstructor) in s(Class), constructor)',
248 'Method(s(Class.redirectingFactory) in s(Class), static, constructor)',
249 'TypeVariable(s(S) in s(Superclass),'
250 ' upperBound = Class(s(Object) in s(dart.core), top-level))',
251 'Method(s(Superclass._inheritedGenerativeConstructor)'
252 ' in s(Superclass), private, constructor)',
253 'Method(s(Superclass._inheritedNormalFactory)'
254 ' in s(Superclass), private, static, constructor)',
255 'Method(s(Superclass._inheritedRedirectingConstructor)'
256 ' in s(Superclass), private, constructor)',
257 'Method(s(Superclass._inheritedRedirectingFactory)'
258 ' in s(Superclass), private, static, constructor)',
259 'Method(s(Superclass.inheritedGenerativeConstructor)'
260 ' in s(Superclass), constructor)',
261 'Method(s(Superclass.inheritedNormalFactory)'
262 ' in s(Superclass), static, constructor)',
263 'Method(s(Superclass.inheritedRedirectingConstructor)'
264 ' in s(Superclass), constructor)',
265 'Method(s(Superclass.inheritedRedirectingFactory)'
266 ' in s(Superclass), static, constructor)',
267 'Method(s(_inheritedInstanceGetter) in s(Superclass), private, getter)',
268 'Method(s(_inheritedInstanceMethod) in s(Superclass), private)',
269 'Method(s(_inheritedInstanceSetter=) in s(Superclass), private, setter)',
270 'Variable(s(_inheritedInstanceVariable) in s(Superclass), private)',
271 'Method(s(_inheritedStaticGetter)'
272 ' in s(Superclass), private, static, getter)',
273 'Method(s(_inheritedStaticMethod) in s(Superclass), private, static)',
274 'Method(s(_inheritedStaticSetter=)'
275 ' in s(Superclass), private, static, setter)',
276 'Variable(s(_inheritedStaticVariable) in s(Superclass), private, static)',
277 'Method(s(_instanceGetter) in s(Class), private, getter)',
278 'Method(s(_instanceMethod) in s(Class), private)',
279 'Method(s(_instanceSetter=) in s(Class), private, setter)',
280 'Variable(s(_instanceVariable) in s(Class), private)',
281 'Method(s(_mixinInstanceGetter) in s(Mixin), private, getter)',
282 'Method(s(_mixinInstanceMethod) in s(Mixin), private)',
283 'Method(s(_mixinInstanceSetter=) in s(Mixin), private, setter)',
284 'Variable(s(_mixinInstanceVariable) in s(Mixin), private)',
285 'Method(s(_staticGetter) in s(Class), private, static, getter)',
286 'Method(s(_staticMethod) in s(Class), private, static)',
287 'Method(s(_staticSetter=) in s(Class), private, static, setter)',
288 'Variable(s(_staticVariable) in s(Class), private, static)',
289 'Method(s(abstractMethod) in s(Class), abstract)',
290 'Method(s(inheritedInstanceGetter) in s(Superclass), getter)',
291 'Method(s(inheritedInstanceMethod) in s(Superclass))',
292 'Method(s(inheritedInstanceSetter=) in s(Superclass), setter)',
293 'Variable(s(inheritedInstanceVariable) in s(Superclass))',
294 'Method(s(inheritedStaticGetter) in s(Superclass), static, getter)',
295 'Method(s(inheritedStaticMethod) in s(Superclass), static)',
296 'Method(s(inheritedStaticSetter=) in s(Superclass), static, setter)',
297 'Variable(s(inheritedStaticVariable) in s(Superclass), static)',
298 'Method(s(instanceGetter) in s(Class), getter)',
299 'Method(s(instanceMethod) in s(Class))',
300 'Method(s(instanceSetter=) in s(Class), setter)',
301 'Variable(s(instanceVariable) in s(Class))',
302 'Method(s(mixinInstanceGetter) in s(Mixin), getter)',
303 'Method(s(mixinInstanceMethod) in s(Mixin))',
304 'Method(s(mixinInstanceSetter=) in s(Mixin), setter)',
305 'Variable(s(mixinInstanceVariable) in s(Mixin))',
306 'Method(s(staticGetter) in s(Class), static, getter)',
307 'Method(s(staticMethod) in s(Class), static)',
308 'Method(s(staticSetter=) in s(Class), static, setter)',
309 'Variable(s(staticVariable) in s(Class), static)',
310 'Method(s(test.declarations_model.Superclass'
311 ' with test.declarations_model.Mixin._inheritedGenerativeConstructor)'
312 ' in s(test.declarations_model.Superclass'
313 ' with test.declarations_model.Mixin), private, constructor)',
314 'Method(s(test.declarations_model.Superclass'
315 ' with test.declarations_model.Mixin._inheritedRedirectingConstructor)'
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.inheritedGenerativeConstructor)'
320 ' in s(test.declarations_model.Superclass'
321 ' with test.declarations_model.Mixin), constructor)',
322 'Method(s(test.declarations_model.Superclass'
323 ' with test.declarations_model.Mixin.inheritedRedirectingConstructor)'
324 ' in s(test.declarations_model.Superclass'
325 ' with test.declarations_model.Mixin), constructor)'],
326 inheritedDeclarations(cm)
327 .difference(reflectClass(Object).declarations.values.toSet())
328 .map(stringify),
329 'transitive less Object');
330 // The private members of Object may vary across implementations, so we
331 // exclude the declarations of Object in this test case.
332 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/declarations_model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698