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

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

Issue 10834061: Resolve typedefs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated scope handling and type resolution Created 8 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 | 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("../../../lib/dartdoc/mirrors/mirrors.dart"); 5 #import("../../../lib/dartdoc/mirrors/mirrors.dart");
6 #import("../../../lib/dartdoc/mirrors/mirrors_util.dart"); 6 #import("../../../lib/dartdoc/mirrors/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) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 Expect.isFalse(bazClass.isFunction, "Class is a function"); 249 Expect.isFalse(bazClass.isFunction, "Class is a function");
250 250
251 Expect.isTrue(bazClass.isDeclaration, "Class is not declaration"); 251 Expect.isTrue(bazClass.isDeclaration, "Class is not declaration");
252 Expect.equals(bazClass, bazClass.declaration, 252 Expect.equals(bazClass, bazClass.declaration,
253 "Class is not its declaration"); 253 "Class is not its declaration");
254 254
255 Expect.isTrue(bazClass.isClass, "Class is not class"); 255 Expect.isTrue(bazClass.isClass, "Class is not class");
256 Expect.isFalse(bazClass.isInterface, "Class is interface"); 256 Expect.isFalse(bazClass.isInterface, "Class is interface");
257 Expect.isFalse(bazClass.isPrivate, "Class is private"); 257 Expect.isFalse(bazClass.isPrivate, "Class is private");
258 258
259 var bazClassTypeVariables = bazClass.typeVariables();
260 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null");
261 Expect.equals(2, bazClassTypeVariables.length,
262 "Type variable list is not empty");
263
264 var bazE = bazClassTypeVariables[0];
265 Expect.isNotNull(bazE, "Type variable is null");
266 Expect.stringEquals('E', bazE.simpleName(), "Unexpected simpleName");
267 Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName(),
268 "Unexpected qualifiedName");
269 Expect.equals(bazClass, bazE.declarer(),
270 "Unexpected type variable declarer");
271 var bazEbound = bazE.bound();
272 Expect.isNotNull(bazEbound, "Missing type variable bound");
273 Expect.isFalse(bazEbound.isDeclaration, "Bound is declaration");
274 Expect.isTrue(bazEbound.isObject, "Bound is not object");
275
276 var bazF = bazClassTypeVariables[1];
277 Expect.isNotNull(bazF, "Type variable is null");
278 Expect.stringEquals('F', bazF.simpleName(), "Unexpected simpleName");
279 Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName(),
280 "Unexpected qualifiedName");
281 Expect.equals(bazClass, bazF.declarer());
282 var bazFbound = bazF.bound();
283 Expect.isNotNull(bazFbound, "Missing type variable bound");
284 Expect.isFalse(bazFbound.isDeclaration, "Bound is declaration");
285 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName(),
286 "Bound is not Foo");
287
259 var objectType = bazClass.superclass(); 288 var objectType = bazClass.superclass();
260 Expect.isNotNull(objectType, "Superclass is null"); 289 Expect.isNotNull(objectType, "Superclass is null");
261 Expect.isTrue(objectType.isObject, "Object is not Object"); 290 Expect.isTrue(objectType.isObject, "Object is not Object");
262 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); 291 Expect.isFalse(objectType.isDeclaration, "Object type is declaration");
263 Expect.isTrue(containsType(bazClass, 292 Expect.isTrue(containsType(bazClass,
264 computeSubdeclarations(objectType)), 293 computeSubdeclarations(objectType)),
265 "Class is not subclass of superclass"); 294 "Class is not subclass of superclass");
266 295
267 var bazInterfaces = bazClass.interfaces(); 296 var bazInterfaces = bazClass.interfaces();
268 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); 297 Expect.isNotNull(bazInterfaces, "Interfaces map is null");
269 Expect.isTrue(!bazInterfaces.isEmpty(), "Interfaces map is empty"); 298 Expect.isTrue(!bazInterfaces.isEmpty(), "Interfaces map is empty");
270 for (var bazInterface in bazInterfaces.getValues()) { 299 for (var bazInterface in bazInterfaces.getValues()) {
271 Expect.isTrue(containsType(bazClass, 300 Expect.isTrue(containsType(bazClass,
272 computeSubdeclarations(objectType)), 301 computeSubdeclarations(objectType)),
273 "Class is not subclass of superinterface"); 302 "Class is not subclass of superinterface");
274 } 303 }
275 304
276 var bazSubdeclarations = computeSubdeclarations(bazClass); 305 var bazSubdeclarations = computeSubdeclarations(bazClass);
277 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); 306 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count");
278 307
279 var barInterface = findMirror(bazInterfaces, "Bar"); 308 var barInterface = findMirror(bazInterfaces, "Bar");
280 Expect.isNotNull(barInterface, "Interface bar is missing"); 309 Expect.isNotNull(barInterface, "Interface bar is missing");
281 Expect.isFalse(barInterface.isDeclaration, "Interface type is declaration"); 310 Expect.isFalse(barInterface.isDeclaration, "Interface type is declaration");
282 var barInterfaceTypeArguments = barInterface.typeArguments(); 311 var barInterfaceTypeArguments = barInterface.typeArguments();
283 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); 312 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing");
284 // TODO(johnniwinther): Ensure type arguments on supertypes. Expected result 313 Expect.equals(1, barInterfaceTypeArguments.length,
285 // should have been 1:
286 Expect.equals(0, barInterfaceTypeArguments.length,
287 "Type arguments is empty"); 314 "Type arguments is empty");
315 Expect.equals(bazE, barInterfaceTypeArguments[0],
316 "Unexpected type argument on super type");
288 317
289 Expect.throws(() => bazClass.typeArguments(), 318 Expect.throws(() => bazClass.typeArguments(),
290 (exception) => true, 319 (exception) => true,
291 "Class has type arguments"); 320 "Class has type arguments");
292 var bazClassTypeVariables = bazClass.typeVariables();
293 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null");
294 Expect.equals(2, bazClassTypeVariables.length,
295 "Type variable list is not empty");
296
297 var bazE = bazClassTypeVariables[0];
298 Expect.isNotNull(bazE, "Type variable is null");
299 Expect.stringEquals('E', bazE.simpleName(), "Unexpected simpleName");
300 Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName(),
301 "Unexpected qualifiedName");
302 Expect.equals(bazClass, bazE.declarer(),
303 "Unexpected type variable declarer");
304 var bazEbound = bazE.bound();
305 Expect.isNotNull(bazEbound, "Missing type variable bound");
306 Expect.isFalse(bazEbound.isDeclaration, "Bound is declaration");
307 Expect.isTrue(bazEbound.isObject, "Bound is not object");
308
309 var bazF = bazClassTypeVariables[1];
310 Expect.isNotNull(bazF, "Type variable is null");
311 Expect.stringEquals('F', bazF.simpleName(), "Unexpected simpleName");
312 Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName(),
313 "Unexpected qualifiedName");
314 Expect.equals(bazClass, bazF.declarer());
315 var bazFbound = bazF.bound();
316 Expect.isNotNull(bazFbound, "Missing type variable bound");
317 Expect.isFalse(bazFbound.isDeclaration, "Bound is declaration");
318 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName(),
319 "Bound is not Foo");
320 321
321 Expect.isNull(bazClass.defaultType(), "Class has default type"); 322 Expect.isNull(bazClass.defaultType(), "Class has default type");
322 323
323 var bazClassMembers = bazClass.declaredMembers(); 324 var bazClassMembers = bazClass.declaredMembers();
324 Expect.isNotNull(bazClassMembers, "Declared members map is null"); 325 Expect.isNotNull(bazClassMembers, "Declared members map is null");
325 Expect.equals(8, bazClassMembers.length, 326 Expect.equals(8, bazClassMembers.length,
326 "Unexpected number of declared members"); 327 "Unexpected number of declared members");
327 328
328 //////////////////////////////////////////////////////////////////////////// 329 ////////////////////////////////////////////////////////////////////////////
329 // method1(e) {} 330 // method1(e) {}
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 Expect.stringEquals('negate', operator_negate.operatorName, 629 Expect.stringEquals('negate', operator_negate.operatorName,
629 "Unexpected operatorName"); 630 "Unexpected operatorName");
630 631
631 632
632 var bazClassConstructors = bazClass.constructors(); 633 var bazClassConstructors = bazClass.constructors();
633 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); 634 Expect.isNotNull(bazClassConstructors, "Constructors map is null");
634 Expect.equals(3, bazClassConstructors.length, 635 Expect.equals(3, bazClassConstructors.length,
635 "Unexpected number of constructors"); 636 "Unexpected number of constructors");
636 // TODO(johnniwinther): Add tests of constructors. 637 // TODO(johnniwinther): Add tests of constructors.
637 } 638 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698