| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 Expect.isFalse(classes.isEmpty, "Empty classes map returned"); | 60 Expect.isFalse(classes.isEmpty, "Empty classes map returned"); |
| 61 | 61 |
| 62 testFoo(mirrors, helperLibrary, classes); | 62 testFoo(mirrors, helperLibrary, classes); |
| 63 testBar(mirrors, helperLibrary, classes); | 63 testBar(mirrors, helperLibrary, classes); |
| 64 testBaz(mirrors, helperLibrary, classes); | 64 testBaz(mirrors, helperLibrary, classes); |
| 65 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. | 65 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. |
| 66 // TODO(johnniwinther): Add tests of type argument substitution, which | 66 // TODO(johnniwinther): Add tests of type argument substitution, which |
| 67 // is not currently implemented in dart2js. | 67 // is not currently implemented in dart2js. |
| 68 // TODO(johnniwinther): Add tests of Location and Source. | 68 // TODO(johnniwinther): Add tests of Location and Source. |
| 69 testPrivate(mirrors, helperLibrary, classes); | 69 testPrivate(mirrors, helperLibrary, classes); |
| 70 // TODO(johnniwinther): Add tests of [LibraryMirror.functions], | 70 // TODO(johnniwinther): Add thorough tests of [LibraryMirror.functions], |
| 71 // [LibraryMirror.getters], [LibraryMirror.setters] and | 71 // [LibraryMirror.getters], [LibraryMirror.setters], [LibraryMirror.members], |
| 72 // [LibraryMirror.members]. | 72 // and [LibraryMirror.variable]. |
| 73 Expect.isNotNull(helperLibrary.functions); |
| 74 Expect.isNotNull(helperLibrary.members); |
| 75 Expect.isNotNull(helperLibrary.getters); |
| 76 Expect.isNotNull(helperLibrary.setters); |
| 77 Expect.isNotNull(helperLibrary.variables); |
| 73 } | 78 } |
| 74 | 79 |
| 75 // Testing class Foo: | 80 // Testing class Foo: |
| 76 // | 81 // |
| 77 // class Foo { | 82 // class Foo { |
| 78 // | 83 // |
| 79 // } | 84 // } |
| 80 void testFoo(MirrorSystem system, LibraryMirror helperLibrary, | 85 void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
| 81 Map<String,TypeMirror> classes) { | 86 Map<String,TypeMirror> classes) { |
| 82 var fooClass = classes["Foo"]; | 87 var fooClass = classes["Foo"]; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 Expect.isNull(fooClass.defaultFactory); | 139 Expect.isNull(fooClass.defaultFactory); |
| 135 | 140 |
| 136 var fooClassMembers = fooClass.declaredMembers; | 141 var fooClassMembers = fooClass.declaredMembers; |
| 137 Expect.isNotNull(fooClassMembers, "Declared members map is null"); | 142 Expect.isNotNull(fooClassMembers, "Declared members map is null"); |
| 138 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); | 143 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); |
| 139 | 144 |
| 140 var fooClassConstructors = fooClass.constructors; | 145 var fooClassConstructors = fooClass.constructors; |
| 141 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); | 146 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); |
| 142 Expect.isTrue(fooClassConstructors.isEmpty, | 147 Expect.isTrue(fooClassConstructors.isEmpty, |
| 143 "Constructors map is unempty"); | 148 "Constructors map is unempty"); |
| 149 |
| 150 // TODO(johnniwinther): Add thorough tests of [ClassMirror.functions], |
| 151 // [ClassMirror.getters], [ClassMirror.setters], [ClassMirror.members], |
| 152 // and [ClassMirror.variable]. |
| 153 Expect.isNotNull(fooClass.functions); |
| 154 Expect.isNotNull(fooClass.members); |
| 155 Expect.isNotNull(fooClass.getters); |
| 156 Expect.isNotNull(fooClass.setters); |
| 157 Expect.isNotNull(fooClass.variables); |
| 144 } | 158 } |
| 145 | 159 |
| 146 // Testing interface Bar: | 160 // Testing interface Bar: |
| 147 // | 161 // |
| 148 // interface Bar<E> { | 162 // interface Bar<E> { |
| 149 // | 163 // |
| 150 // } | 164 // } |
| 151 void testBar(MirrorSystem system, LibraryMirror helperLibrary, | 165 void testBar(MirrorSystem system, LibraryMirror helperLibrary, |
| 152 Map<String,TypeMirror> classes) { | 166 Map<String,TypeMirror> classes) { |
| 153 var barInterface = classes["Bar"]; | 167 var barInterface = classes["Bar"]; |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, | 703 void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, |
| 690 Map<String,TypeMirror> classes) { | 704 Map<String,TypeMirror> classes) { |
| 691 var privateClass = classes['_PrivateClass']; | 705 var privateClass = classes['_PrivateClass']; |
| 692 Expect.isNotNull(privateClass); | 706 Expect.isNotNull(privateClass); |
| 693 Expect.isTrue(privateClass is ClassMirror); | 707 Expect.isTrue(privateClass is ClassMirror); |
| 694 Expect.isTrue(privateClass.isClass); | 708 Expect.isTrue(privateClass.isClass); |
| 695 Expect.isTrue(privateClass.isPrivate); | 709 Expect.isTrue(privateClass.isPrivate); |
| 696 | 710 |
| 697 var privateField = privateClass.declaredMembers['_privateField']; | 711 var privateField = privateClass.declaredMembers['_privateField']; |
| 698 Expect.isNotNull(privateField); | 712 Expect.isNotNull(privateField); |
| 699 Expect.isTrue(privateField is FieldMirror); | 713 Expect.isTrue(privateField is VariableMirror); |
| 700 Expect.isTrue(privateField.isPrivate); | 714 Expect.isTrue(privateField.isPrivate); |
| 701 | 715 |
| 702 var privateGetter = privateClass.declaredMembers['_privateGetter']; | 716 var privateGetter = privateClass.declaredMembers['_privateGetter']; |
| 703 Expect.isNotNull(privateGetter); | 717 Expect.isNotNull(privateGetter); |
| 704 Expect.isTrue(privateGetter is MethodMirror); | 718 Expect.isTrue(privateGetter is MethodMirror); |
| 705 Expect.isTrue(privateGetter.isGetter); | 719 Expect.isTrue(privateGetter.isGetter); |
| 706 Expect.isTrue(privateGetter.isPrivate); | 720 Expect.isTrue(privateGetter.isPrivate); |
| 707 | 721 |
| 708 var privateSetter = privateClass.declaredMembers['_privateSetter=']; | 722 var privateSetter = privateClass.declaredMembers['_privateSetter=']; |
| 709 Expect.isNotNull(privateSetter); | 723 Expect.isNotNull(privateSetter); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 723 Expect.isTrue(privateConstructor.isConstructor); | 737 Expect.isTrue(privateConstructor.isConstructor); |
| 724 Expect.isTrue(privateConstructor.isPrivate); | 738 Expect.isTrue(privateConstructor.isPrivate); |
| 725 | 739 |
| 726 var privateFactoryConstructor = | 740 var privateFactoryConstructor = |
| 727 privateClass.declaredMembers['_PrivateClass._privateFactoryConstructor']; | 741 privateClass.declaredMembers['_PrivateClass._privateFactoryConstructor']; |
| 728 Expect.isNotNull(privateFactoryConstructor); | 742 Expect.isNotNull(privateFactoryConstructor); |
| 729 Expect.isTrue(privateFactoryConstructor is MethodMirror); | 743 Expect.isTrue(privateFactoryConstructor is MethodMirror); |
| 730 Expect.isTrue(privateFactoryConstructor.isFactory); | 744 Expect.isTrue(privateFactoryConstructor.isFactory); |
| 731 Expect.isTrue(privateFactoryConstructor.isPrivate); | 745 Expect.isTrue(privateFactoryConstructor.isPrivate); |
| 732 } | 746 } |
| OLD | NEW |