| OLD | NEW |
| 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) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 Expect.throws(() => fooClass.typeArguments, | 131 Expect.throws(() => fooClass.typeArguments, |
| 132 (exception) => true, | 132 (exception) => true, |
| 133 "Class has type arguments"); | 133 "Class has type arguments"); |
| 134 var fooClassTypeVariables = fooClass.typeVariables; | 134 var fooClassTypeVariables = fooClass.typeVariables; |
| 135 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); | 135 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); |
| 136 Expect.isTrue(fooClassTypeVariables.isEmpty, | 136 Expect.isTrue(fooClassTypeVariables.isEmpty, |
| 137 "Type variable list is not empty"); | 137 "Type variable list is not empty"); |
| 138 | 138 |
| 139 Expect.isNull(fooClass.defaultFactory); | 139 Expect.isNull(fooClass.defaultFactory); |
| 140 | 140 |
| 141 var fooClassMembers = fooClass.declaredMembers; | 141 var fooClassMembers = fooClass.members; |
| 142 Expect.isNotNull(fooClassMembers, "Declared members map is null"); | 142 Expect.isNotNull(fooClassMembers, "Declared members map is null"); |
| 143 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); | 143 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); |
| 144 | 144 |
| 145 var fooClassConstructors = fooClass.constructors; | 145 var fooClassConstructors = fooClass.constructors; |
| 146 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); | 146 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); |
| 147 Expect.isTrue(fooClassConstructors.isEmpty, | 147 Expect.isTrue(fooClassConstructors.isEmpty, |
| 148 "Constructors map is unempty"); | 148 "Constructors map is unempty"); |
| 149 | 149 |
| 150 // TODO(johnniwinther): Add thorough tests of [ClassMirror.functions], | 150 // TODO(johnniwinther): Add thorough tests of [ClassMirror.functions], |
| 151 // [ClassMirror.getters], [ClassMirror.setters], [ClassMirror.members], | 151 // [ClassMirror.getters], [ClassMirror.setters], [ClassMirror.members], |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 "Type variable list is empty"); | 219 "Type variable list is empty"); |
| 220 Expect.equals(barInterfaceTypeVariables.length, 1, | 220 Expect.equals(barInterfaceTypeVariables.length, 1, |
| 221 "Unexpected number of type variables"); | 221 "Unexpected number of type variables"); |
| 222 | 222 |
| 223 var barE = barInterfaceTypeVariables[0]; | 223 var barE = barInterfaceTypeVariables[0]; |
| 224 Expect.isNotNull(barE, "Type variable is null"); | 224 Expect.isNotNull(barE, "Type variable is null"); |
| 225 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); | 225 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); |
| 226 | 226 |
| 227 Expect.isNull(barInterface.defaultFactory); | 227 Expect.isNull(barInterface.defaultFactory); |
| 228 | 228 |
| 229 var barInterfaceMembers = barInterface.declaredMembers; | 229 var barInterfaceMembers = barInterface.members; |
| 230 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); | 230 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); |
| 231 Expect.isTrue(barInterfaceMembers.isEmpty, | 231 Expect.isTrue(barInterfaceMembers.isEmpty, |
| 232 "Declared members map is unempty"); | 232 "Declared members map is unempty"); |
| 233 | 233 |
| 234 var barInterfaceConstructors = barInterface.constructors; | 234 var barInterfaceConstructors = barInterface.constructors; |
| 235 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); | 235 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); |
| 236 Expect.isTrue(barInterfaceConstructors.isEmpty, | 236 Expect.isTrue(barInterfaceConstructors.isEmpty, |
| 237 "Constructors map is unempty"); | 237 "Constructors map is unempty"); |
| 238 } | 238 } |
| 239 | 239 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 "Unexpected qualifiedName"); | 334 "Unexpected qualifiedName"); |
| 335 Expect.equals(bazClass, bazF.declarer); | 335 Expect.equals(bazClass, bazF.declarer); |
| 336 var bazFbound = bazF.upperBound; | 336 var bazFbound = bazF.upperBound; |
| 337 Expect.isNotNull(bazFbound); | 337 Expect.isNotNull(bazFbound); |
| 338 Expect.isFalse(bazFbound.isOriginalDeclaration); | 338 Expect.isFalse(bazFbound.isOriginalDeclaration); |
| 339 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName, | 339 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName, |
| 340 "Bound is not Foo"); | 340 "Bound is not Foo"); |
| 341 | 341 |
| 342 Expect.isNull(bazClass.defaultFactory); | 342 Expect.isNull(bazClass.defaultFactory); |
| 343 | 343 |
| 344 var bazClassMembers = bazClass.declaredMembers; | 344 var bazClassMembers = bazClass.members; |
| 345 Expect.isNotNull(bazClassMembers, "Declared members map is null"); | 345 Expect.isNotNull(bazClassMembers, "Declared members map is null"); |
| 346 Expect.equals(8, bazClassMembers.length, | 346 Expect.equals(8, bazClassMembers.length, |
| 347 "Unexpected number of declared members"); | 347 "Unexpected number of declared members"); |
| 348 | 348 |
| 349 //////////////////////////////////////////////////////////////////////////// | 349 //////////////////////////////////////////////////////////////////////////// |
| 350 // static method1(e) {} | 350 // static method1(e) {} |
| 351 //////////////////////////////////////////////////////////////////////////// | 351 //////////////////////////////////////////////////////////////////////////// |
| 352 var method1 = bazClassMembers["method1"]; | 352 var method1 = bazClassMembers["method1"]; |
| 353 Expect.isNotNull(method1, "method1 not found"); | 353 Expect.isNotNull(method1, "method1 not found"); |
| 354 Expect.stringEquals('method1', method1.simpleName, | 354 Expect.stringEquals('method1', method1.simpleName, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); | 546 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); |
| 547 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); | 547 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); |
| 548 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); | 548 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); |
| 549 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); | 549 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); |
| 550 | 550 |
| 551 Expect.equals(helperLibrary, funcTypedef.library, | 551 Expect.equals(helperLibrary, funcTypedef.library, |
| 552 "Unexpected typedef library"); | 552 "Unexpected typedef library"); |
| 553 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef"); | 553 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef"); |
| 554 Expect.isNotNull(funcTypedef.superinterfaces); | 554 Expect.isNotNull(funcTypedef.superinterfaces); |
| 555 Expect.isTrue(funcTypedef.superinterfaces.isEmpty); | 555 Expect.isTrue(funcTypedef.superinterfaces.isEmpty); |
| 556 Expect.isNotNull(funcTypedef.declaredMembers, | 556 Expect.isNotNull(funcTypedef.members); |
| 557 "Declared members map is null on type def"); | 557 Expect.isTrue(funcTypedef.members.isEmpty); |
| 558 Expect.isTrue(funcTypedef.declaredMembers.isEmpty, | |
| 559 "Non-empty declared members map on typedef"); | |
| 560 | 558 |
| 561 // TODO(johnniwinther): Returned typedef should not be the original | 559 // TODO(johnniwinther): Returned typedef should not be the original |
| 562 // declaration: | 560 // declaration: |
| 563 Expect.isTrue(funcTypedef.isOriginalDeclaration); | 561 Expect.isTrue(funcTypedef.isOriginalDeclaration); |
| 564 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); | 562 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); |
| 565 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); | 563 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); |
| 566 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); | 564 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); |
| 567 Expect.isNull(funcTypedef.defaultFactory); | 565 Expect.isNull(funcTypedef.defaultFactory); |
| 568 // TODO(johnniwinther): Should not throw an exception since the type should | 566 // TODO(johnniwinther): Should not throw an exception since the type should |
| 569 // not be the original declaration. | 567 // not be the original declaration. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 // factory _PrivateClass._privateFactoryConstructor() => new _PrivateClass(); | 699 // factory _PrivateClass._privateFactoryConstructor() => new _PrivateClass(); |
| 702 // } | 700 // } |
| 703 void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, | 701 void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, |
| 704 Map<String,TypeMirror> classes) { | 702 Map<String,TypeMirror> classes) { |
| 705 var privateClass = classes['_PrivateClass']; | 703 var privateClass = classes['_PrivateClass']; |
| 706 Expect.isNotNull(privateClass); | 704 Expect.isNotNull(privateClass); |
| 707 Expect.isTrue(privateClass is ClassMirror); | 705 Expect.isTrue(privateClass is ClassMirror); |
| 708 Expect.isTrue(privateClass.isClass); | 706 Expect.isTrue(privateClass.isClass); |
| 709 Expect.isTrue(privateClass.isPrivate); | 707 Expect.isTrue(privateClass.isPrivate); |
| 710 | 708 |
| 711 var privateField = privateClass.declaredMembers['_privateField']; | 709 var privateField = privateClass.members['_privateField']; |
| 712 Expect.isNotNull(privateField); | 710 Expect.isNotNull(privateField); |
| 713 Expect.isTrue(privateField is VariableMirror); | 711 Expect.isTrue(privateField is VariableMirror); |
| 714 Expect.isTrue(privateField.isPrivate); | 712 Expect.isTrue(privateField.isPrivate); |
| 715 | 713 |
| 716 var privateGetter = privateClass.declaredMembers['_privateGetter']; | 714 var privateGetter = privateClass.members['_privateGetter']; |
| 717 Expect.isNotNull(privateGetter); | 715 Expect.isNotNull(privateGetter); |
| 718 Expect.isTrue(privateGetter is MethodMirror); | 716 Expect.isTrue(privateGetter is MethodMirror); |
| 719 Expect.isTrue(privateGetter.isGetter); | 717 Expect.isTrue(privateGetter.isGetter); |
| 720 Expect.isTrue(privateGetter.isPrivate); | 718 Expect.isTrue(privateGetter.isPrivate); |
| 721 | 719 |
| 722 var privateSetter = privateClass.declaredMembers['_privateSetter=']; | 720 var privateSetter = privateClass.members['_privateSetter=']; |
| 723 Expect.isNotNull(privateSetter); | 721 Expect.isNotNull(privateSetter); |
| 724 Expect.isTrue(privateSetter is MethodMirror); | 722 Expect.isTrue(privateSetter is MethodMirror); |
| 725 Expect.isTrue(privateSetter.isSetter); | 723 Expect.isTrue(privateSetter.isSetter); |
| 726 Expect.isTrue(privateSetter.isPrivate); | 724 Expect.isTrue(privateSetter.isPrivate); |
| 727 | 725 |
| 728 var privateMethod = privateClass.declaredMembers['_privateMethod']; | 726 var privateMethod = privateClass.members['_privateMethod']; |
| 729 Expect.isNotNull(privateMethod); | 727 Expect.isNotNull(privateMethod); |
| 730 Expect.isTrue(privateMethod is MethodMirror); | 728 Expect.isTrue(privateMethod is MethodMirror); |
| 731 Expect.isTrue(privateMethod.isPrivate); | 729 Expect.isTrue(privateMethod.isPrivate); |
| 732 | 730 |
| 733 var privateConstructor = | 731 var privateConstructor = |
| 734 privateClass.declaredMembers['_PrivateClass._privateConstructor']; | 732 privateClass.members['_PrivateClass._privateConstructor']; |
| 735 Expect.isNotNull(privateConstructor); | 733 Expect.isNotNull(privateConstructor); |
| 736 Expect.isTrue(privateConstructor is MethodMirror); | 734 Expect.isTrue(privateConstructor is MethodMirror); |
| 737 Expect.isTrue(privateConstructor.isConstructor); | 735 Expect.isTrue(privateConstructor.isConstructor); |
| 738 Expect.isTrue(privateConstructor.isPrivate); | 736 Expect.isTrue(privateConstructor.isPrivate); |
| 739 | 737 |
| 740 var privateFactoryConstructor = | 738 var privateFactoryConstructor = |
| 741 privateClass.declaredMembers['_PrivateClass._privateFactoryConstructor']; | 739 privateClass.members['_PrivateClass._privateFactoryConstructor']; |
| 742 Expect.isNotNull(privateFactoryConstructor); | 740 Expect.isNotNull(privateFactoryConstructor); |
| 743 Expect.isTrue(privateFactoryConstructor is MethodMirror); | 741 Expect.isTrue(privateFactoryConstructor is MethodMirror); |
| 744 Expect.isTrue(privateFactoryConstructor.isFactory); | 742 Expect.isTrue(privateFactoryConstructor.isFactory); |
| 745 Expect.isTrue(privateFactoryConstructor.isPrivate); | 743 Expect.isTrue(privateFactoryConstructor.isPrivate); |
| 746 } | 744 } |
| OLD | NEW |