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

Side by Side Diff: tests/compiler/dart2js/mirrors_test.dart

Issue 11348036: Alignments for the ClassMirror interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #import("../../../pkg/dartdoc/lib/mirrors.dart"); 5 #import("../../../pkg/dartdoc/lib/mirrors.dart");
6 #import("../../../pkg/dartdoc/lib/mirrors_util.dart"); 6 #import("../../../pkg/dartdoc/lib/mirrors_util.dart");
7 7
8 #import('dart:io'); 8 #import('dart:io');
9 9
10 int count(Iterable iterable) { 10 int count(Iterable iterable) {
11 var count = 0; 11 var count = 0;
12 for (var element in iterable) { 12 for (var element in iterable) {
13 count++; 13 count++;
14 } 14 }
15 return count; 15 return count;
16 } 16 }
17 17
18 bool containsType(TypeMirror expected, Iterable<TypeMirror> iterable) { 18 bool containsType(TypeMirror expected, Iterable<TypeMirror> iterable) {
19 for (var element in iterable) { 19 for (var element in iterable) {
20 if (element.declaration == expected.declaration) { 20 if (element.originalDeclaration == expected.originalDeclaration) {
21 return true; 21 return true;
22 } 22 }
23 } 23 }
24 return false; 24 return false;
25 } 25 }
26 26
27 DeclarationMirror findMirror(List<DeclarationMirror> list, String name) { 27 DeclarationMirror findMirror(List<DeclarationMirror> list, String name) {
28 for (DeclarationMirror mirror in list) { 28 for (DeclarationMirror mirror in list) {
29 if (mirror.simpleName == name) { 29 if (mirror.simpleName == name) {
30 return mirror; 30 return mirror;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 Expect.equals(helperLibrary, fooClass.library, 91 Expect.equals(helperLibrary, fooClass.library,
92 "Unexpected library returned from type"); 92 "Unexpected library returned from type");
93 93
94 Expect.isFalse(fooClass.isObject, "Class is Object"); 94 Expect.isFalse(fooClass.isObject, "Class is Object");
95 Expect.isFalse(fooClass.isDynamic, "Class is Dynamic"); 95 Expect.isFalse(fooClass.isDynamic, "Class is Dynamic");
96 Expect.isFalse(fooClass.isVoid, "Class is void"); 96 Expect.isFalse(fooClass.isVoid, "Class is void");
97 Expect.isFalse(fooClass.isTypeVariable, "Class is a type variable"); 97 Expect.isFalse(fooClass.isTypeVariable, "Class is a type variable");
98 Expect.isFalse(fooClass.isTypedef, "Class is a typedef"); 98 Expect.isFalse(fooClass.isTypedef, "Class is a typedef");
99 Expect.isFalse(fooClass.isFunction, "Class is a function"); 99 Expect.isFalse(fooClass.isFunction, "Class is a function");
100 100
101 Expect.isTrue(fooClass.isDeclaration, "Class is not declaration"); 101 Expect.isTrue(fooClass.isOriginalDeclaration);
102 Expect.equals(fooClass, fooClass.declaration, 102 Expect.equals(fooClass, fooClass.originalDeclaration);
103 "Class is not its declaration");
104 103
105 Expect.isTrue(fooClass.isClass, "Class is not class"); 104 Expect.isTrue(fooClass.isClass, "Class is not class");
106 Expect.isFalse(fooClass.isInterface, "Class is interface"); 105 Expect.isFalse(fooClass.isInterface, "Class is interface");
107 Expect.isFalse(fooClass.isPrivate, "Class is private"); 106 Expect.isFalse(fooClass.isPrivate, "Class is private");
108 107
109 var objectType = fooClass.superclass; 108 var objectType = fooClass.superclass;
110 Expect.isNotNull(objectType, "Superclass is null"); 109 Expect.isNotNull(objectType, "Superclass is null");
111 Expect.isTrue(objectType.isObject, "Object is not Object"); 110 Expect.isTrue(objectType.isObject, "Object is not Object");
112 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); 111 Expect.isFalse(objectType.isOriginalDeclaration);
113 Expect.isTrue(containsType(fooClass, 112 Expect.isTrue(containsType(fooClass,
114 computeSubdeclarations(objectType)), 113 computeSubdeclarations(objectType)),
115 "Class is not subclass of superclass"); 114 "Class is not subclass of superclass");
116 115
117 var fooInterfaces = fooClass.interfaces; 116 var fooInterfaces = fooClass.superinterfaces;
118 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); 117 Expect.isNotNull(fooInterfaces, "Interfaces map is null");
119 Expect.isTrue(fooInterfaces.isEmpty, "Interfaces map is not empty"); 118 Expect.isTrue(fooInterfaces.isEmpty, "Interfaces map is not empty");
120 119
121 var fooSubdeclarations = computeSubdeclarations(fooClass); 120 var fooSubdeclarations = computeSubdeclarations(fooClass);
122 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); 121 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count");
123 for (var fooSubdeclaration in fooSubdeclarations) { 122 for (var fooSubdeclaration in fooSubdeclarations) {
124 Expect.equals(fooClass, fooSubdeclaration.superclass.declaration, 123 Expect.equals(fooClass, fooSubdeclaration.superclass.originalDeclaration);
125 "Class is not superclass of subclass");
126 } 124 }
127 125
128 Expect.throws(() => fooClass.typeArguments, 126 Expect.throws(() => fooClass.typeArguments,
129 (exception) => true, 127 (exception) => true,
130 "Class has type arguments"); 128 "Class has type arguments");
131 var fooClassTypeVariables = fooClass.typeVariables; 129 var fooClassTypeVariables = fooClass.typeVariables;
132 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); 130 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null");
133 Expect.isTrue(fooClassTypeVariables.isEmpty, 131 Expect.isTrue(fooClassTypeVariables.isEmpty,
134 "Type variable list is not empty"); 132 "Type variable list is not empty");
135 133
136 Expect.isNull(fooClass.defaultType, "Class has default type"); 134 Expect.isNull(fooClass.defaultFactory);
137 135
138 var fooClassMembers = fooClass.declaredMembers; 136 var fooClassMembers = fooClass.declaredMembers;
139 Expect.isNotNull(fooClassMembers, "Declared members map is null"); 137 Expect.isNotNull(fooClassMembers, "Declared members map is null");
140 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); 138 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty");
141 139
142 var fooClassConstructors = fooClass.constructors; 140 var fooClassConstructors = fooClass.constructors;
143 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); 141 Expect.isNotNull(fooClassConstructors, "Constructors map is null");
144 Expect.isTrue(fooClassConstructors.isEmpty, 142 Expect.isTrue(fooClassConstructors.isEmpty,
145 "Constructors map is unempty"); 143 "Constructors map is unempty");
146 } 144 }
(...skipping 17 matching lines...) Expand all
164 Expect.equals(helperLibrary, barInterface.library, 162 Expect.equals(helperLibrary, barInterface.library,
165 "Unexpected library returned from type"); 163 "Unexpected library returned from type");
166 164
167 Expect.isFalse(barInterface.isObject, "Interface is Object"); 165 Expect.isFalse(barInterface.isObject, "Interface is Object");
168 Expect.isFalse(barInterface.isDynamic, "Interface is Dynamic"); 166 Expect.isFalse(barInterface.isDynamic, "Interface is Dynamic");
169 Expect.isFalse(barInterface.isVoid, "Interface is void"); 167 Expect.isFalse(barInterface.isVoid, "Interface is void");
170 Expect.isFalse(barInterface.isTypeVariable, "Interface is a type variable"); 168 Expect.isFalse(barInterface.isTypeVariable, "Interface is a type variable");
171 Expect.isFalse(barInterface.isTypedef, "Interface is a typedef"); 169 Expect.isFalse(barInterface.isTypedef, "Interface is a typedef");
172 Expect.isFalse(barInterface.isFunction, "Interface is a function"); 170 Expect.isFalse(barInterface.isFunction, "Interface is a function");
173 171
174 Expect.isTrue(barInterface.isDeclaration, "Interface is not declaration"); 172 Expect.isTrue(barInterface.isOriginalDeclaration);
175 Expect.equals(barInterface, barInterface.declaration, 173 Expect.equals(barInterface, barInterface.originalDeclaration);
176 "Interface is not its declaration");
177 174
178 Expect.isFalse(barInterface.isClass, "Interface is class"); 175 Expect.isFalse(barInterface.isClass, "Interface is class");
179 Expect.isTrue(barInterface.isInterface, "Interface is not interface"); 176 Expect.isTrue(barInterface.isInterface, "Interface is not interface");
180 Expect.isFalse(barInterface.isPrivate, "Interface is private"); 177 Expect.isFalse(barInterface.isPrivate, "Interface is private");
181 178
182 var objectType = barInterface.superclass; 179 var objectType = barInterface.superclass;
183 Expect.isNotNull(objectType, "Superclass is null"); 180 Expect.isNotNull(objectType, "Superclass is null");
184 Expect.isTrue(objectType.isObject, "Object is not Object"); 181 Expect.isTrue(objectType.isObject, "Object is not Object");
185 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); 182 Expect.isFalse(objectType.isOriginalDeclaration);
186 Expect.isTrue(containsType(barInterface, 183 Expect.isTrue(containsType(barInterface,
187 computeSubdeclarations(objectType)), 184 computeSubdeclarations(objectType)),
188 "Class is not subclass of superclass"); 185 "Class is not subclass of superclass");
189 186
190 var barInterfaces = barInterface.interfaces; 187 var barInterfaces = barInterface.superinterfaces;
191 Expect.isNotNull(barInterfaces, "Interfaces map is null"); 188 Expect.isNotNull(barInterfaces, "Interfaces map is null");
192 Expect.isTrue(barInterfaces.isEmpty, "Interfaces map is not empty"); 189 Expect.isTrue(barInterfaces.isEmpty, "Interfaces map is not empty");
193 190
194 var barSubdeclarations = computeSubdeclarations(barInterface); 191 var barSubdeclarations = computeSubdeclarations(barInterface);
195 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); 192 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count");
196 for (var barSubdeclaration in barSubdeclarations) { 193 for (var barSubdeclaration in barSubdeclarations) {
197 Expect.isTrue(containsType(barInterface, 194 Expect.isTrue(containsType(barInterface,
198 barSubdeclaration.interfaces), 195 barSubdeclaration.superinterfaces),
199 "Interface is not superinterface of subclass"); 196 "Interface is not superinterface of subclass");
200 } 197 }
201 198
202 Expect.throws(() => barInterface.typeArguments, 199 Expect.throws(() => barInterface.typeArguments,
203 (exception) => true, 200 (exception) => true,
204 "Interface has type arguments"); 201 "Interface has type arguments");
205 var barInterfaceTypeVariables = barInterface.typeVariables; 202 var barInterfaceTypeVariables = barInterface.typeVariables;
206 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null"); 203 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null");
207 Expect.isFalse(barInterfaceTypeVariables.isEmpty, 204 Expect.isFalse(barInterfaceTypeVariables.isEmpty,
208 "Type variable list is empty"); 205 "Type variable list is empty");
209 Expect.equals(barInterfaceTypeVariables.length, 1, 206 Expect.equals(barInterfaceTypeVariables.length, 1,
210 "Unexpected number of type variables"); 207 "Unexpected number of type variables");
211 208
212 var barE = barInterfaceTypeVariables[0]; 209 var barE = barInterfaceTypeVariables[0];
213 Expect.isNotNull(barE, "Type variable is null"); 210 Expect.isNotNull(barE, "Type variable is null");
214 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); 211 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable");
215 212
216 Expect.isNull(barInterface.defaultType, "Interface has default type"); 213 Expect.isNull(barInterface.defaultFactory);
217 214
218 var barInterfaceMembers = barInterface.declaredMembers; 215 var barInterfaceMembers = barInterface.declaredMembers;
219 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); 216 Expect.isNotNull(barInterfaceMembers, "Declared members map is null");
220 Expect.isTrue(barInterfaceMembers.isEmpty, 217 Expect.isTrue(barInterfaceMembers.isEmpty,
221 "Declared members map is unempty"); 218 "Declared members map is unempty");
222 219
223 var barInterfaceConstructors = barInterface.constructors; 220 var barInterfaceConstructors = barInterface.constructors;
224 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); 221 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null");
225 Expect.isTrue(barInterfaceConstructors.isEmpty, 222 Expect.isTrue(barInterfaceConstructors.isEmpty,
226 "Constructors map is unempty"); 223 "Constructors map is unempty");
(...skipping 27 matching lines...) Expand all
254 Expect.equals(helperLibrary, bazClass.library, 251 Expect.equals(helperLibrary, bazClass.library,
255 "Unexpected library returned from type"); 252 "Unexpected library returned from type");
256 253
257 Expect.isFalse(bazClass.isObject, "Class is Object"); 254 Expect.isFalse(bazClass.isObject, "Class is Object");
258 Expect.isFalse(bazClass.isDynamic, "Class is Dynamic"); 255 Expect.isFalse(bazClass.isDynamic, "Class is Dynamic");
259 Expect.isFalse(bazClass.isVoid, "Class is void"); 256 Expect.isFalse(bazClass.isVoid, "Class is void");
260 Expect.isFalse(bazClass.isTypeVariable, "Class is a type variable"); 257 Expect.isFalse(bazClass.isTypeVariable, "Class is a type variable");
261 Expect.isFalse(bazClass.isTypedef, "Class is a typedef"); 258 Expect.isFalse(bazClass.isTypedef, "Class is a typedef");
262 Expect.isFalse(bazClass.isFunction, "Class is a function"); 259 Expect.isFalse(bazClass.isFunction, "Class is a function");
263 260
264 Expect.isTrue(bazClass.isDeclaration, "Class is not declaration"); 261 Expect.isTrue(bazClass.isOriginalDeclaration);
265 Expect.equals(bazClass, bazClass.declaration, 262 Expect.equals(bazClass, bazClass.originalDeclaration);
266 "Class is not its declaration");
267 263
268 Expect.isTrue(bazClass.isClass, "Class is not class"); 264 Expect.isTrue(bazClass.isClass, "Class is not class");
269 Expect.isFalse(bazClass.isInterface, "Class is interface"); 265 Expect.isFalse(bazClass.isInterface, "Class is interface");
270 Expect.isFalse(bazClass.isPrivate, "Class is private"); 266 Expect.isFalse(bazClass.isPrivate, "Class is private");
271 267
272 var objectType = bazClass.superclass; 268 var objectType = bazClass.superclass;
273 Expect.isNotNull(objectType, "Superclass is null"); 269 Expect.isNotNull(objectType, "Superclass is null");
274 Expect.isTrue(objectType.isObject, "Object is not Object"); 270 Expect.isTrue(objectType.isObject, "Object is not Object");
275 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); 271 Expect.isFalse(objectType.isOriginalDeclaration);
276 Expect.isTrue(containsType(bazClass, 272 Expect.isTrue(containsType(bazClass,
277 computeSubdeclarations(objectType)), 273 computeSubdeclarations(objectType)),
278 "Class is not subclass of superclass"); 274 "Class is not subclass of superclass");
279 275
280 var bazInterfaces = bazClass.interfaces; 276 var bazInterfaces = bazClass.superinterfaces;
281 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); 277 Expect.isNotNull(bazInterfaces, "Interfaces map is null");
282 Expect.isTrue(!bazInterfaces.isEmpty, "Interfaces map is empty"); 278 Expect.isTrue(!bazInterfaces.isEmpty, "Interfaces map is empty");
283 for (var bazInterface in bazInterfaces) { 279 for (var bazInterface in bazInterfaces) {
284 Expect.isTrue(containsType(bazClass, 280 Expect.isTrue(containsType(bazClass,
285 computeSubdeclarations(objectType)), 281 computeSubdeclarations(objectType)),
286 "Class is not subclass of superinterface"); 282 "Class is not subclass of superinterface");
287 } 283 }
288 284
289 var bazSubdeclarations = computeSubdeclarations(bazClass); 285 var bazSubdeclarations = computeSubdeclarations(bazClass);
290 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); 286 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count");
291 287
292 var barInterface = findMirror(bazInterfaces, "Bar"); 288 var barInterface = findMirror(bazInterfaces, "Bar");
293 Expect.isNotNull(barInterface, "Interface bar is missing"); 289 Expect.isNotNull(barInterface, "Interface bar is missing");
294 Expect.isFalse(barInterface.isDeclaration, "Interface type is declaration"); 290 Expect.isFalse(barInterface.isOriginalDeclaration);
295 var barInterfaceTypeArguments = barInterface.typeArguments; 291 var barInterfaceTypeArguments = barInterface.typeArguments;
296 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); 292 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing");
297 Expect.equals(1, barInterfaceTypeArguments.length, 293 Expect.equals(1, barInterfaceTypeArguments.length,
298 "Type arguments is empty"); 294 "Type arguments is empty");
299 295
300 Expect.throws(() => bazClass.typeArguments, 296 Expect.throws(() => bazClass.typeArguments,
301 (exception) => true, 297 (exception) => true,
302 "Class has type arguments"); 298 "Class has type arguments");
303 var bazClassTypeVariables = bazClass.typeVariables; 299 var bazClassTypeVariables = bazClass.typeVariables;
304 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null"); 300 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null");
305 Expect.equals(2, bazClassTypeVariables.length, 301 Expect.equals(2, bazClassTypeVariables.length,
306 "Type variable list is not empty"); 302 "Type variable list is not empty");
307 303
308 var bazE = bazClassTypeVariables[0]; 304 var bazE = bazClassTypeVariables[0];
309 Expect.isNotNull(bazE, "Type variable is null"); 305 Expect.isNotNull(bazE, "Type variable is null");
310 Expect.stringEquals('E', bazE.simpleName, "Unexpected simpleName"); 306 Expect.stringEquals('E', bazE.simpleName, "Unexpected simpleName");
311 Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName, 307 Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName,
312 "Unexpected qualifiedName"); 308 "Unexpected qualifiedName");
313 Expect.equals(bazClass, bazE.declarer, 309 Expect.equals(bazClass, bazE.declarer,
314 "Unexpected type variable declarer"); 310 "Unexpected type variable declarer");
315 var bazEbound = bazE.bound; 311 var bazEbound = bazE.bound;
316 Expect.isNotNull(bazEbound, "Missing type variable bound"); 312 Expect.isNotNull(bazEbound, "Missing type variable bound");
317 Expect.isFalse(bazEbound.isDeclaration, "Bound is declaration"); 313 Expect.isFalse(bazEbound.isOriginalDeclaration);
318 Expect.isTrue(bazEbound.isObject, "Bound is not object"); 314 Expect.isTrue(bazEbound.isObject, "Bound is not object");
319 315
320 var bazF = bazClassTypeVariables[1]; 316 var bazF = bazClassTypeVariables[1];
321 Expect.isNotNull(bazF, "Type variable is null"); 317 Expect.isNotNull(bazF, "Type variable is null");
322 Expect.stringEquals('F', bazF.simpleName, "Unexpected simpleName"); 318 Expect.stringEquals('F', bazF.simpleName, "Unexpected simpleName");
323 Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName, 319 Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName,
324 "Unexpected qualifiedName"); 320 "Unexpected qualifiedName");
325 Expect.equals(bazClass, bazF.declarer); 321 Expect.equals(bazClass, bazF.declarer);
326 var bazFbound = bazF.bound; 322 var bazFbound = bazF.bound;
327 Expect.isNotNull(bazFbound, "Missing type variable bound"); 323 Expect.isNotNull(bazFbound, "Missing type variable bound");
328 Expect.isFalse(bazFbound.isDeclaration, "Bound is declaration"); 324 Expect.isFalse(bazFbound.isOriginalDeclaration);
329 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName, 325 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName,
330 "Bound is not Foo"); 326 "Bound is not Foo");
331 327
332 Expect.isNull(bazClass.defaultType, "Class has default type"); 328 Expect.isNull(bazClass.defaultFactory);
333 329
334 var bazClassMembers = bazClass.declaredMembers; 330 var bazClassMembers = bazClass.declaredMembers;
335 Expect.isNotNull(bazClassMembers, "Declared members map is null"); 331 Expect.isNotNull(bazClassMembers, "Declared members map is null");
336 Expect.equals(8, bazClassMembers.length, 332 Expect.equals(8, bazClassMembers.length,
337 "Unexpected number of declared members"); 333 "Unexpected number of declared members");
338 334
339 //////////////////////////////////////////////////////////////////////////// 335 ////////////////////////////////////////////////////////////////////////////
340 // static method1(e) {} 336 // static method1(e) {}
341 //////////////////////////////////////////////////////////////////////////// 337 ////////////////////////////////////////////////////////////////////////////
342 var method1 = bazClassMembers["method1"]; 338 var method1 = bazClassMembers["method1"];
343 Expect.isNotNull(method1, "method1 not found"); 339 Expect.isNotNull(method1, "method1 not found");
344 Expect.stringEquals('method1', method1.simpleName, 340 Expect.stringEquals('method1', method1.simpleName,
345 "Unexpected method simpleName"); 341 "Unexpected method simpleName");
346 Expect.stringEquals('mirrors_helper.Baz.method1', method1.qualifiedName, 342 Expect.stringEquals('mirrors_helper.Baz.method1', method1.qualifiedName,
347 "Unexpected method qualifiedName"); 343 "Unexpected method qualifiedName");
348 Expect.equals(method1.owner, bazClass, 344 Expect.equals(method1.owner, bazClass);
349 "Unexpected surrounding declaration");
350 Expect.isFalse(method1.isTopLevel, "Method is top level"); 345 Expect.isFalse(method1.isTopLevel, "Method is top level");
351 Expect.isFalse(method1.isConstructor, "Method is constructor"); 346 Expect.isFalse(method1.isConstructor, "Method is constructor");
352 Expect.isFalse(method1.isField, "Method is field"); 347 Expect.isFalse(method1.isField, "Method is field");
353 Expect.isTrue(method1.isMethod, "Method is not method"); 348 Expect.isTrue(method1.isMethod, "Method is not method");
354 Expect.isFalse(method1.isPrivate, "Method is private"); 349 Expect.isFalse(method1.isPrivate, "Method is private");
355 Expect.isTrue(method1.isStatic, "Method is not static"); 350 Expect.isTrue(method1.isStatic, "Method is not static");
356 Expect.isTrue(method1 is MethodMirror, "Method is not MethodMirror"); 351 Expect.isTrue(method1 is MethodMirror, "Method is not MethodMirror");
357 Expect.isFalse(method1.isConst, "Method is const"); 352 Expect.isFalse(method1.isConst, "Method is const");
358 Expect.isFalse(method1.isFactory, "Method is factory"); 353 Expect.isFalse(method1.isFactory, "Method is factory");
359 Expect.isNull(method1.constructorName, 354 Expect.isNull(method1.constructorName,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 387
393 //////////////////////////////////////////////////////////////////////////// 388 ////////////////////////////////////////////////////////////////////////////
394 // static void method2(E e, [F f = null]) {} 389 // static void method2(E e, [F f = null]) {}
395 //////////////////////////////////////////////////////////////////////////// 390 ////////////////////////////////////////////////////////////////////////////
396 var method2 = bazClassMembers["method2"]; 391 var method2 = bazClassMembers["method2"];
397 Expect.isNotNull(method2, "method2 not found"); 392 Expect.isNotNull(method2, "method2 not found");
398 Expect.stringEquals('method2', method2.simpleName, 393 Expect.stringEquals('method2', method2.simpleName,
399 "Unexpected method simpleName"); 394 "Unexpected method simpleName");
400 Expect.stringEquals('mirrors_helper.Baz.method2', method2.qualifiedName, 395 Expect.stringEquals('mirrors_helper.Baz.method2', method2.qualifiedName,
401 "Unexpected method qualifiedName"); 396 "Unexpected method qualifiedName");
402 Expect.equals(method2.owner, bazClass, 397 Expect.equals(method2.owner, bazClass);
403 "Unexpected surrounding declaration");
404 Expect.isFalse(method2.isTopLevel, "Method is top level"); 398 Expect.isFalse(method2.isTopLevel, "Method is top level");
405 Expect.isFalse(method2.isConstructor, "Method is constructor"); 399 Expect.isFalse(method2.isConstructor, "Method is constructor");
406 Expect.isFalse(method2.isField, "Method is field"); 400 Expect.isFalse(method2.isField, "Method is field");
407 Expect.isTrue(method2.isMethod, "Method is not method"); 401 Expect.isTrue(method2.isMethod, "Method is not method");
408 Expect.isFalse(method2.isPrivate, "Method is private"); 402 Expect.isFalse(method2.isPrivate, "Method is private");
409 Expect.isFalse(method2.isStatic, "Method is static"); 403 Expect.isFalse(method2.isStatic, "Method is static");
410 Expect.isTrue(method2 is MethodMirror, "Method is not MethodMirror"); 404 Expect.isTrue(method2 is MethodMirror, "Method is not MethodMirror");
411 Expect.isFalse(method2.isConst, "Method is const"); 405 Expect.isFalse(method2.isConst, "Method is const");
412 Expect.isFalse(method2.isFactory, "Method is factory"); 406 Expect.isFalse(method2.isFactory, "Method is factory");
413 Expect.isNull(method2.constructorName, 407 Expect.isNull(method2.constructorName,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 453
460 //////////////////////////////////////////////////////////////////////////// 454 ////////////////////////////////////////////////////////////////////////////
461 // Baz<E,F> method3(E func1(F f), Func<E,F> func2) => null; 455 // Baz<E,F> method3(E func1(F f), Func<E,F> func2) => null;
462 //////////////////////////////////////////////////////////////////////////// 456 ////////////////////////////////////////////////////////////////////////////
463 var method3 = bazClassMembers["method3"]; 457 var method3 = bazClassMembers["method3"];
464 Expect.isNotNull(method3, "method3 not found"); 458 Expect.isNotNull(method3, "method3 not found");
465 Expect.stringEquals('method3', method3.simpleName, 459 Expect.stringEquals('method3', method3.simpleName,
466 "Unexpected method simpleName"); 460 "Unexpected method simpleName");
467 Expect.stringEquals('mirrors_helper.Baz.method3', method3.qualifiedName, 461 Expect.stringEquals('mirrors_helper.Baz.method3', method3.qualifiedName,
468 "Unexpected method qualifiedName"); 462 "Unexpected method qualifiedName");
469 Expect.equals(method3.owner, bazClass, 463 Expect.equals(method3.owner, bazClass);
470 "Unexpected surrounding declaration");
471 Expect.isFalse(method3.isTopLevel, "Method is top level"); 464 Expect.isFalse(method3.isTopLevel, "Method is top level");
472 Expect.isFalse(method3.isConstructor, "Method is constructor"); 465 Expect.isFalse(method3.isConstructor, "Method is constructor");
473 Expect.isFalse(method3.isField, "Method is field"); 466 Expect.isFalse(method3.isField, "Method is field");
474 Expect.isTrue(method3.isMethod, "Method is not method"); 467 Expect.isTrue(method3.isMethod, "Method is not method");
475 Expect.isFalse(method3.isPrivate, "Method is private"); 468 Expect.isFalse(method3.isPrivate, "Method is private");
476 Expect.isFalse(method3.isStatic, "Method is static"); 469 Expect.isFalse(method3.isStatic, "Method is static");
477 Expect.isTrue(method3 is MethodMirror, "Method is not MethodMirror"); 470 Expect.isTrue(method3 is MethodMirror, "Method is not MethodMirror");
478 Expect.isFalse(method3.isConst, "Method is const"); 471 Expect.isFalse(method3.isConst, "Method is const");
479 Expect.isFalse(method3.isFactory, "Method is factory"); 472 Expect.isFalse(method3.isFactory, "Method is factory");
480 Expect.isNull(method3.constructorName, 473 Expect.isNull(method3.constructorName,
481 "Method constructorName is non-null"); 474 "Method constructorName is non-null");
482 Expect.isFalse(method3.isGetter, "Method is getter"); 475 Expect.isFalse(method3.isGetter, "Method is getter");
483 Expect.isFalse(method3.isSetter, "Method is setter"); 476 Expect.isFalse(method3.isSetter, "Method is setter");
484 Expect.isFalse(method3.isOperator, "Method is operator"); 477 Expect.isFalse(method3.isOperator, "Method is operator");
485 Expect.isNull(method3.operatorName, 478 Expect.isNull(method3.operatorName,
486 "Method operatorName is non-null"); 479 "Method operatorName is non-null");
487 480
488 var method3ReturnType = method3.returnType; 481 var method3ReturnType = method3.returnType;
489 Expect.isNotNull(method3ReturnType, "Return type is null"); 482 Expect.isNotNull(method3ReturnType, "Return type is null");
490 Expect.isTrue(method3ReturnType is ClassMirror, 483 Expect.isTrue(method3ReturnType is ClassMirror,
491 "Return type is not interface"); 484 "Return type is not interface");
492 Expect.equals(bazClass, method3ReturnType.declaration, 485 Expect.equals(bazClass, method3ReturnType.originalDeclaration);
493 "Return type is not Baz");
494 // TODO(johnniwinther): Test type arguments of [method3ReturnType]. 486 // TODO(johnniwinther): Test type arguments of [method3ReturnType].
495 487
496 var method3Parameters = method3.parameters; 488 var method3Parameters = method3.parameters;
497 Expect.isNotNull(method3Parameters, "Method parameters is null"); 489 Expect.isNotNull(method3Parameters, "Method parameters is null");
498 Expect.equals(2, method3Parameters.length, "Unexpected parameter count"); 490 Expect.equals(2, method3Parameters.length, "Unexpected parameter count");
499 var method3Parameter1 = method3Parameters[0]; 491 var method3Parameter1 = method3Parameters[0];
500 Expect.isNotNull(method3Parameter1, "Parameter is null"); 492 Expect.isNotNull(method3Parameter1, "Parameter is null");
501 var method3Parameter1type = method3Parameter1.type; 493 var method3Parameter1type = method3Parameter1.type;
502 Expect.isNotNull(method3Parameter1type, "Parameter type of 'func1' is null"); 494 Expect.isNotNull(method3Parameter1type, "Parameter type of 'func1' is null");
503 Expect.isTrue(method3Parameter1type is FunctionTypeMirror, 495 Expect.isTrue(method3Parameter1type is FunctionTypeMirror,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 Expect.isFalse(funcTypedef.isObject, "Typedef is Object"); 530 Expect.isFalse(funcTypedef.isObject, "Typedef is Object");
539 Expect.isFalse(funcTypedef.isDynamic, "Typedef is Dynamic"); 531 Expect.isFalse(funcTypedef.isDynamic, "Typedef is Dynamic");
540 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); 532 Expect.isFalse(funcTypedef.isVoid, "Typedef is void");
541 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); 533 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable");
542 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); 534 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef");
543 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); 535 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function");
544 536
545 Expect.equals(helperLibrary, funcTypedef.library, 537 Expect.equals(helperLibrary, funcTypedef.library,
546 "Unexpected typedef library"); 538 "Unexpected typedef library");
547 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef"); 539 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef");
548 Expect.isNotNull(funcTypedef.interfaces, 540 Expect.isNotNull(funcTypedef.superinterfaces);
549 "Null interfaces map on typedef"); 541 Expect.isTrue(funcTypedef.superinterfaces.isEmpty);
550 Expect.isTrue(funcTypedef.interfaces.isEmpty,
551 "Non-empty interfaces map on typedef");
552 Expect.isNotNull(funcTypedef.declaredMembers, 542 Expect.isNotNull(funcTypedef.declaredMembers,
553 "Declared members map is null on type def"); 543 "Declared members map is null on type def");
554 Expect.isTrue(funcTypedef.declaredMembers.isEmpty, 544 Expect.isTrue(funcTypedef.declaredMembers.isEmpty,
555 "Non-empty declared members map on typedef"); 545 "Non-empty declared members map on typedef");
556 546
557 // TODO(johnniwinther): Returned typedef should not be the declaration: 547 // TODO(johnniwinther): Returned typedef should not be the original
558 Expect.isTrue(funcTypedef.isDeclaration, "Typedef is not declaration"); 548 // declaration:
549 Expect.isTrue(funcTypedef.isOriginalDeclaration);
559 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); 550 Expect.isFalse(funcTypedef.isClass, "Typedef is class");
560 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); 551 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface");
561 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); 552 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private");
562 Expect.isNull(funcTypedef.defaultType, 553 Expect.isNull(funcTypedef.defaultFactory);
563 "Typedef default type is non-null");
564 // TODO(johnniwinther): Should not throw an exception since the type should 554 // TODO(johnniwinther): Should not throw an exception since the type should
565 // not be the declaration. 555 // not be the original declaration.
566 Expect.throws(() => funcTypedef.typeArguments, 556 Expect.throws(() => funcTypedef.typeArguments,
567 (exception) => true, 557 (exception) => true,
568 "Typedef has type arguments"); 558 "Typedef has type arguments");
569 var funcTypedefTypeVariables = funcTypedef.typeVariables; 559 var funcTypedefTypeVariables = funcTypedef.typeVariables;
570 Expect.isNotNull(funcTypedefTypeVariables); 560 Expect.isNotNull(funcTypedefTypeVariables);
571 Expect.equals(2, funcTypedefTypeVariables.length); 561 Expect.equals(2, funcTypedefTypeVariables.length);
572 562
573 var funcTypedefDefinition = funcTypedef.definition; 563 var funcTypedefDefinition = funcTypedef.definition;
574 Expect.isNotNull(funcTypedefDefinition); 564 Expect.isNotNull(funcTypedefDefinition);
575 Expect.isTrue(funcTypedefDefinition is FunctionTypeMirror); 565 Expect.isTrue(funcTypedefDefinition is FunctionTypeMirror);
(...skipping 14 matching lines...) Expand all
590 // bool operator==(Object other) => false; 580 // bool operator==(Object other) => false;
591 //////////////////////////////////////////////////////////////////////////// 581 ////////////////////////////////////////////////////////////////////////////
592 var operator_eq = bazClassMembers['==']; 582 var operator_eq = bazClassMembers['=='];
593 Expect.isNotNull(operator_eq, "operator == not found"); 583 Expect.isNotNull(operator_eq, "operator == not found");
594 Expect.stringEquals('==', operator_eq.simpleName, 584 Expect.stringEquals('==', operator_eq.simpleName,
595 "Unexpected method simpleName"); 585 "Unexpected method simpleName");
596 Expect.stringEquals('operator ==', operator_eq.displayName); 586 Expect.stringEquals('operator ==', operator_eq.displayName);
597 Expect.stringEquals('mirrors_helper.Baz.==', 587 Expect.stringEquals('mirrors_helper.Baz.==',
598 operator_eq.qualifiedName, 588 operator_eq.qualifiedName,
599 "Unexpected method qualifiedName"); 589 "Unexpected method qualifiedName");
600 Expect.equals(operator_eq.owner, bazClass, 590 Expect.equals(operator_eq.owner, bazClass);
601 "Unexpected surrounding declaration");
602 Expect.isFalse(operator_eq.isTopLevel, "Method is top level"); 591 Expect.isFalse(operator_eq.isTopLevel, "Method is top level");
603 Expect.isFalse(operator_eq.isConstructor, "Method is constructor"); 592 Expect.isFalse(operator_eq.isConstructor, "Method is constructor");
604 Expect.isFalse(operator_eq.isField, "Method is field"); 593 Expect.isFalse(operator_eq.isField, "Method is field");
605 Expect.isTrue(operator_eq.isMethod, "Method is not method"); 594 Expect.isTrue(operator_eq.isMethod, "Method is not method");
606 Expect.isFalse(operator_eq.isPrivate, "Method is private"); 595 Expect.isFalse(operator_eq.isPrivate, "Method is private");
607 Expect.isFalse(operator_eq.isStatic, "Method is static"); 596 Expect.isFalse(operator_eq.isStatic, "Method is static");
608 Expect.isTrue(operator_eq is MethodMirror, "Method is not MethodMirror"); 597 Expect.isTrue(operator_eq is MethodMirror, "Method is not MethodMirror");
609 Expect.isFalse(operator_eq.isConst, "Method is const"); 598 Expect.isFalse(operator_eq.isConst, "Method is const");
610 Expect.isFalse(operator_eq.isFactory, "Method is factory"); 599 Expect.isFalse(operator_eq.isFactory, "Method is factory");
611 Expect.isNull(operator_eq.constructorName, 600 Expect.isNull(operator_eq.constructorName,
612 "Method constructorName is non-null"); 601 "Method constructorName is non-null");
613 Expect.isFalse(operator_eq.isGetter, "Method is getter"); 602 Expect.isFalse(operator_eq.isGetter, "Method is getter");
614 Expect.isFalse(operator_eq.isSetter, "Method is setter"); 603 Expect.isFalse(operator_eq.isSetter, "Method is setter");
615 Expect.isTrue(operator_eq.isOperator, "Method is not operator"); 604 Expect.isTrue(operator_eq.isOperator, "Method is not operator");
616 Expect.stringEquals('==', operator_eq.operatorName, 605 Expect.stringEquals('==', operator_eq.operatorName,
617 "Unexpected operatorName"); 606 "Unexpected operatorName");
618 607
619 //////////////////////////////////////////////////////////////////////////// 608 ////////////////////////////////////////////////////////////////////////////
620 // int operator -() => 0; 609 // int operator -() => 0;
621 //////////////////////////////////////////////////////////////////////////// 610 ////////////////////////////////////////////////////////////////////////////
622 var operator_negate = bazClassMembers[Mirror.UNARY_MINUS]; 611 var operator_negate = bazClassMembers[Mirror.UNARY_MINUS];
623 Expect.isNotNull(operator_negate, "operator < not found"); 612 Expect.isNotNull(operator_negate, "operator < not found");
624 Expect.stringEquals(Mirror.UNARY_MINUS, operator_negate.simpleName, 613 Expect.stringEquals(Mirror.UNARY_MINUS, operator_negate.simpleName,
625 "Unexpected method simpleName"); 614 "Unexpected method simpleName");
626 Expect.stringEquals('operator -', operator_negate.displayName); 615 Expect.stringEquals('operator -', operator_negate.displayName);
627 Expect.stringEquals('mirrors_helper.Baz.${Mirror.UNARY_MINUS}', 616 Expect.stringEquals('mirrors_helper.Baz.${Mirror.UNARY_MINUS}',
628 operator_negate.qualifiedName, 617 operator_negate.qualifiedName,
629 "Unexpected method qualifiedName"); 618 "Unexpected method qualifiedName");
630 Expect.equals(operator_negate.owner, bazClass, 619 Expect.equals(operator_negate.owner, bazClass);
631 "Unexpected surrounding declaration");
632 Expect.isFalse(operator_negate.isTopLevel, "Method is top level"); 620 Expect.isFalse(operator_negate.isTopLevel, "Method is top level");
633 Expect.isFalse(operator_negate.isConstructor, "Method is constructor"); 621 Expect.isFalse(operator_negate.isConstructor, "Method is constructor");
634 Expect.isFalse(operator_negate.isField, "Method is field"); 622 Expect.isFalse(operator_negate.isField, "Method is field");
635 Expect.isTrue(operator_negate.isMethod, "Method is not method"); 623 Expect.isTrue(operator_negate.isMethod, "Method is not method");
636 Expect.isFalse(operator_negate.isPrivate, "Method is private"); 624 Expect.isFalse(operator_negate.isPrivate, "Method is private");
637 Expect.isFalse(operator_negate.isStatic, "Method is static"); 625 Expect.isFalse(operator_negate.isStatic, "Method is static");
638 Expect.isTrue(operator_negate is MethodMirror, 626 Expect.isTrue(operator_negate is MethodMirror,
639 "Method is not MethodMirror"); 627 "Method is not MethodMirror");
640 Expect.isFalse(operator_negate.isConst, "Method is const"); 628 Expect.isFalse(operator_negate.isConst, "Method is const");
641 Expect.isFalse(operator_negate.isFactory, "Method is factory"); 629 Expect.isFalse(operator_negate.isFactory, "Method is factory");
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 Expect.isTrue(privateConstructor.isConstructor); 723 Expect.isTrue(privateConstructor.isConstructor);
736 Expect.isTrue(privateConstructor.isPrivate); 724 Expect.isTrue(privateConstructor.isPrivate);
737 725
738 var privateFactoryConstructor = 726 var privateFactoryConstructor =
739 privateClass.declaredMembers['_PrivateClass._privateFactoryConstructor']; 727 privateClass.declaredMembers['_PrivateClass._privateFactoryConstructor'];
740 Expect.isNotNull(privateFactoryConstructor); 728 Expect.isNotNull(privateFactoryConstructor);
741 Expect.isTrue(privateFactoryConstructor is MethodMirror); 729 Expect.isTrue(privateFactoryConstructor is MethodMirror);
742 Expect.isTrue(privateFactoryConstructor.isFactory); 730 Expect.isTrue(privateFactoryConstructor.isFactory);
743 Expect.isTrue(privateFactoryConstructor.isPrivate); 731 Expect.isTrue(privateFactoryConstructor.isPrivate);
744 } 732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698