| 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("../../../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 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 main() { | 27 main() { |
| 28 var scriptPath = new Path.fromNative(new Options().script); | 28 var scriptPath = new Path.fromNative(new Options().script); |
| 29 var dirPath = scriptPath.directoryPath; | 29 var dirPath = scriptPath.directoryPath; |
| 30 var libPath = dirPath.join(new Path.fromNative('../../../')); | 30 var libPath = dirPath.join(new Path.fromNative('../../../')); |
| 31 var inputPath = dirPath.join(new Path.fromNative('mirrors_helper.dart')); | 31 var inputPath = dirPath.join(new Path.fromNative('mirrors_helper.dart')); |
| 32 var compilation = new Compilation(inputPath, libPath); | 32 var compilation = new Compilation(inputPath, libPath); |
| 33 Expect.isNotNull(compilation, "No compilation created"); | 33 Expect.isNotNull(compilation, "No compilation created"); |
| 34 | 34 |
| 35 var mirrors = compilation.mirrors(); | 35 var mirrors = compilation.mirrors; |
| 36 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); | 36 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); |
| 37 | 37 |
| 38 var libraries = mirrors.libraries(); | 38 var libraries = mirrors.libraries; |
| 39 Expect.isNotNull(libraries, "No libraries map returned"); | 39 Expect.isNotNull(libraries, "No libraries map returned"); |
| 40 Expect.isFalse(libraries.isEmpty(), "Empty libraries map returned"); | 40 Expect.isFalse(libraries.isEmpty(), "Empty libraries map returned"); |
| 41 | 41 |
| 42 var helperLibrary = findMirror(libraries, "mirrors_helper"); | 42 var helperLibrary = findMirror(libraries, "mirrors_helper"); |
| 43 Expect.isNotNull(helperLibrary, "Library 'mirrors_helper' not found"); | 43 Expect.isNotNull(helperLibrary, "Library 'mirrors_helper' not found"); |
| 44 Expect.stringEquals("mirrors_helper", helperLibrary.simpleName(), | 44 Expect.stringEquals("mirrors_helper", helperLibrary.simpleName, |
| 45 "Unexpected library simple name"); | 45 "Unexpected library simple name"); |
| 46 Expect.stringEquals("mirrors_helper", helperLibrary.qualifiedName(), | 46 Expect.stringEquals("mirrors_helper", helperLibrary.qualifiedName, |
| 47 "Unexpected library qualified name"); | 47 "Unexpected library qualified name"); |
| 48 | 48 |
| 49 var types = helperLibrary.types(); | 49 var types = helperLibrary.types; |
| 50 Expect.isNotNull(types, "No types map returned"); | 50 Expect.isNotNull(types, "No types map returned"); |
| 51 Expect.isFalse(types.isEmpty(), "Empty types map returned"); | 51 Expect.isFalse(types.isEmpty(), "Empty types map returned"); |
| 52 | 52 |
| 53 testFoo(mirrors, helperLibrary, types); | 53 testFoo(mirrors, helperLibrary, types); |
| 54 testBar(mirrors, helperLibrary, types); | 54 testBar(mirrors, helperLibrary, types); |
| 55 testBaz(mirrors, helperLibrary, types); | 55 testBaz(mirrors, helperLibrary, types); |
| 56 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. | 56 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. |
| 57 // TODO(johnniwinther): Add tests of type argument substitution, which | 57 // TODO(johnniwinther): Add tests of type argument substitution, which |
| 58 // is not currently implemented in dart2js. | 58 // is not currently implemented in dart2js. |
| 59 // TODO(johnniwinther): Add tests of Location and Source. | 59 // TODO(johnniwinther): Add tests of Location and Source. |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Testing class Foo: | 62 // Testing class Foo: |
| 63 // | 63 // |
| 64 // class Foo { | 64 // class Foo { |
| 65 // | 65 // |
| 66 // } | 66 // } |
| 67 void testFoo(MirrorSystem system, LibraryMirror helperLibrary, | 67 void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
| 68 Map<Object,TypeMirror> types) { | 68 Map<Object,TypeMirror> types) { |
| 69 var fooClass = findMirror(types, "Foo"); | 69 var fooClass = findMirror(types, "Foo"); |
| 70 Expect.isNotNull(fooClass, "Type 'Foo' not found"); | 70 Expect.isNotNull(fooClass, "Type 'Foo' not found"); |
| 71 Expect.isTrue(fooClass is InterfaceMirror, | 71 Expect.isTrue(fooClass is InterfaceMirror, |
| 72 "Unexpected mirror type returned"); | 72 "Unexpected mirror type returned"); |
| 73 Expect.stringEquals("Foo", fooClass.simpleName(), | 73 Expect.stringEquals("Foo", fooClass.simpleName, |
| 74 "Unexpected type simple name"); | 74 "Unexpected type simple name"); |
| 75 Expect.stringEquals("mirrors_helper.Foo", fooClass.qualifiedName(), | 75 Expect.stringEquals("mirrors_helper.Foo", fooClass.qualifiedName, |
| 76 "Unexpected type qualified name"); | 76 "Unexpected type qualified name"); |
| 77 | 77 |
| 78 Expect.equals(helperLibrary, fooClass.library(), | 78 Expect.equals(helperLibrary, fooClass.library, |
| 79 "Unexpected library returned from type"); | 79 "Unexpected library returned from type"); |
| 80 | 80 |
| 81 Expect.isFalse(fooClass.isObject, "Class is Object"); | 81 Expect.isFalse(fooClass.isObject, "Class is Object"); |
| 82 Expect.isFalse(fooClass.isDynamic, "Class is Dynamic"); | 82 Expect.isFalse(fooClass.isDynamic, "Class is Dynamic"); |
| 83 Expect.isFalse(fooClass.isVoid, "Class is void"); | 83 Expect.isFalse(fooClass.isVoid, "Class is void"); |
| 84 Expect.isFalse(fooClass.isTypeVariable, "Class is a type variable"); | 84 Expect.isFalse(fooClass.isTypeVariable, "Class is a type variable"); |
| 85 Expect.isFalse(fooClass.isTypedef, "Class is a typedef"); | 85 Expect.isFalse(fooClass.isTypedef, "Class is a typedef"); |
| 86 Expect.isFalse(fooClass.isFunction, "Class is a function"); | 86 Expect.isFalse(fooClass.isFunction, "Class is a function"); |
| 87 | 87 |
| 88 Expect.isTrue(fooClass.isDeclaration, "Class is not declaration"); | 88 Expect.isTrue(fooClass.isDeclaration, "Class is not declaration"); |
| 89 Expect.equals(fooClass, fooClass.declaration, | 89 Expect.equals(fooClass, fooClass.declaration, |
| 90 "Class is not its declaration"); | 90 "Class is not its declaration"); |
| 91 | 91 |
| 92 Expect.isTrue(fooClass.isClass, "Class is not class"); | 92 Expect.isTrue(fooClass.isClass, "Class is not class"); |
| 93 Expect.isFalse(fooClass.isInterface, "Class is interface"); | 93 Expect.isFalse(fooClass.isInterface, "Class is interface"); |
| 94 Expect.isFalse(fooClass.isPrivate, "Class is private"); | 94 Expect.isFalse(fooClass.isPrivate, "Class is private"); |
| 95 | 95 |
| 96 var objectType = fooClass.superclass(); | 96 var objectType = fooClass.superclass; |
| 97 Expect.isNotNull(objectType, "Superclass is null"); | 97 Expect.isNotNull(objectType, "Superclass is null"); |
| 98 Expect.isTrue(objectType.isObject, "Object is not Object"); | 98 Expect.isTrue(objectType.isObject, "Object is not Object"); |
| 99 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); | 99 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); |
| 100 Expect.isTrue(containsType(fooClass, | 100 Expect.isTrue(containsType(fooClass, |
| 101 computeSubdeclarations(objectType)), | 101 computeSubdeclarations(objectType)), |
| 102 "Class is not subclass of superclass"); | 102 "Class is not subclass of superclass"); |
| 103 | 103 |
| 104 var fooInterfaces = fooClass.interfaces(); | 104 var fooInterfaces = fooClass.interfaces; |
| 105 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); | 105 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); |
| 106 Expect.isTrue(fooInterfaces.isEmpty(), "Interfaces map is not empty"); | 106 Expect.isTrue(fooInterfaces.isEmpty(), "Interfaces map is not empty"); |
| 107 | 107 |
| 108 var fooSubdeclarations = computeSubdeclarations(fooClass); | 108 var fooSubdeclarations = computeSubdeclarations(fooClass); |
| 109 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); | 109 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); |
| 110 for (var fooSubdeclaration in fooSubdeclarations) { | 110 for (var fooSubdeclaration in fooSubdeclarations) { |
| 111 Expect.equals(fooClass, fooSubdeclaration.superclass().declaration, | 111 Expect.equals(fooClass, fooSubdeclaration.superclass.declaration, |
| 112 "Class is not superclass of subclass"); | 112 "Class is not superclass of subclass"); |
| 113 } | 113 } |
| 114 | 114 |
| 115 Expect.throws(() => fooClass.typeArguments(), | 115 Expect.throws(() => fooClass.typeArguments, |
| 116 (exception) => true, | 116 (exception) => true, |
| 117 "Class has type arguments"); | 117 "Class has type arguments"); |
| 118 var fooClassTypeVariables = fooClass.typeVariables(); | 118 var fooClassTypeVariables = fooClass.typeVariables; |
| 119 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); | 119 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); |
| 120 Expect.isTrue(fooClassTypeVariables.isEmpty(), | 120 Expect.isTrue(fooClassTypeVariables.isEmpty(), |
| 121 "Type variable list is not empty"); | 121 "Type variable list is not empty"); |
| 122 | 122 |
| 123 Expect.isNull(fooClass.defaultType(), "Class has default type"); | 123 Expect.isNull(fooClass.defaultType, "Class has default type"); |
| 124 | 124 |
| 125 var fooClassMembers = fooClass.declaredMembers(); | 125 var fooClassMembers = fooClass.declaredMembers; |
| 126 Expect.isNotNull(fooClassMembers, "Declared members map is null"); | 126 Expect.isNotNull(fooClassMembers, "Declared members map is null"); |
| 127 Expect.isTrue(fooClassMembers.isEmpty(), "Declared members map is unempty"); | 127 Expect.isTrue(fooClassMembers.isEmpty(), "Declared members map is unempty"); |
| 128 | 128 |
| 129 var fooClassConstructors = fooClass.constructors(); | 129 var fooClassConstructors = fooClass.constructors; |
| 130 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); | 130 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); |
| 131 Expect.isTrue(fooClassConstructors.isEmpty(), | 131 Expect.isTrue(fooClassConstructors.isEmpty(), |
| 132 "Constructors map is unempty"); | 132 "Constructors map is unempty"); |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Testing interface Bar: | 135 // Testing interface Bar: |
| 136 // | 136 // |
| 137 // interface Bar<E> { | 137 // interface Bar<E> { |
| 138 // | 138 // |
| 139 // } | 139 // } |
| 140 void testBar(MirrorSystem system, LibraryMirror helperLibrary, | 140 void testBar(MirrorSystem system, LibraryMirror helperLibrary, |
| 141 Map<Object,TypeMirror> types) { | 141 Map<Object,TypeMirror> types) { |
| 142 var barInterface = findMirror(types, "Bar"); | 142 var barInterface = findMirror(types, "Bar"); |
| 143 Expect.isNotNull(barInterface, "Type 'Bar' not found"); | 143 Expect.isNotNull(barInterface, "Type 'Bar' not found"); |
| 144 Expect.isTrue(barInterface is InterfaceMirror, | 144 Expect.isTrue(barInterface is InterfaceMirror, |
| 145 "Unexpected mirror type returned"); | 145 "Unexpected mirror type returned"); |
| 146 Expect.stringEquals("Bar", barInterface.simpleName(), | 146 Expect.stringEquals("Bar", barInterface.simpleName, |
| 147 "Unexpected type simple name"); | 147 "Unexpected type simple name"); |
| 148 Expect.stringEquals("mirrors_helper.Bar", barInterface.qualifiedName(), | 148 Expect.stringEquals("mirrors_helper.Bar", barInterface.qualifiedName, |
| 149 "Unexpected type qualified name"); | 149 "Unexpected type qualified name"); |
| 150 | 150 |
| 151 Expect.equals(helperLibrary, barInterface.library(), | 151 Expect.equals(helperLibrary, barInterface.library, |
| 152 "Unexpected library returned from type"); | 152 "Unexpected library returned from type"); |
| 153 | 153 |
| 154 Expect.isFalse(barInterface.isObject, "Interface is Object"); | 154 Expect.isFalse(barInterface.isObject, "Interface is Object"); |
| 155 Expect.isFalse(barInterface.isDynamic, "Interface is Dynamic"); | 155 Expect.isFalse(barInterface.isDynamic, "Interface is Dynamic"); |
| 156 Expect.isFalse(barInterface.isVoid, "Interface is void"); | 156 Expect.isFalse(barInterface.isVoid, "Interface is void"); |
| 157 Expect.isFalse(barInterface.isTypeVariable, "Interface is a type variable"); | 157 Expect.isFalse(barInterface.isTypeVariable, "Interface is a type variable"); |
| 158 Expect.isFalse(barInterface.isTypedef, "Interface is a typedef"); | 158 Expect.isFalse(barInterface.isTypedef, "Interface is a typedef"); |
| 159 Expect.isFalse(barInterface.isFunction, "Interface is a function"); | 159 Expect.isFalse(barInterface.isFunction, "Interface is a function"); |
| 160 | 160 |
| 161 Expect.isTrue(barInterface.isDeclaration, "Interface is not declaration"); | 161 Expect.isTrue(barInterface.isDeclaration, "Interface is not declaration"); |
| 162 Expect.equals(barInterface, barInterface.declaration, | 162 Expect.equals(barInterface, barInterface.declaration, |
| 163 "Interface is not its declaration"); | 163 "Interface is not its declaration"); |
| 164 | 164 |
| 165 Expect.isFalse(barInterface.isClass, "Interface is class"); | 165 Expect.isFalse(barInterface.isClass, "Interface is class"); |
| 166 Expect.isTrue(barInterface.isInterface, "Interface is not interface"); | 166 Expect.isTrue(barInterface.isInterface, "Interface is not interface"); |
| 167 Expect.isFalse(barInterface.isPrivate, "Interface is private"); | 167 Expect.isFalse(barInterface.isPrivate, "Interface is private"); |
| 168 | 168 |
| 169 var objectType = barInterface.superclass(); | 169 var objectType = barInterface.superclass; |
| 170 Expect.isNotNull(objectType, "Superclass is null"); | 170 Expect.isNotNull(objectType, "Superclass is null"); |
| 171 Expect.isTrue(objectType.isObject, "Object is not Object"); | 171 Expect.isTrue(objectType.isObject, "Object is not Object"); |
| 172 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); | 172 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); |
| 173 Expect.isTrue(containsType(barInterface, | 173 Expect.isTrue(containsType(barInterface, |
| 174 computeSubdeclarations(objectType)), | 174 computeSubdeclarations(objectType)), |
| 175 "Class is not subclass of superclass"); | 175 "Class is not subclass of superclass"); |
| 176 | 176 |
| 177 var barInterfaces = barInterface.interfaces(); | 177 var barInterfaces = barInterface.interfaces; |
| 178 Expect.isNotNull(barInterfaces, "Interfaces map is null"); | 178 Expect.isNotNull(barInterfaces, "Interfaces map is null"); |
| 179 Expect.isTrue(barInterfaces.isEmpty(), "Interfaces map is not empty"); | 179 Expect.isTrue(barInterfaces.isEmpty(), "Interfaces map is not empty"); |
| 180 | 180 |
| 181 var barSubdeclarations = computeSubdeclarations(barInterface); | 181 var barSubdeclarations = computeSubdeclarations(barInterface); |
| 182 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); | 182 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); |
| 183 for (var barSubdeclaration in barSubdeclarations) { | 183 for (var barSubdeclaration in barSubdeclarations) { |
| 184 Expect.isTrue(containsType(barInterface, | 184 Expect.isTrue(containsType(barInterface, |
| 185 barSubdeclaration.interfaces().getValues()), | 185 barSubdeclaration.interfaces.getValues()), |
| 186 "Interface is not superinterface of subclass"); | 186 "Interface is not superinterface of subclass"); |
| 187 } | 187 } |
| 188 | 188 |
| 189 Expect.throws(() => barInterface.typeArguments(), | 189 Expect.throws(() => barInterface.typeArguments, |
| 190 (exception) => true, | 190 (exception) => true, |
| 191 "Interface has type arguments"); | 191 "Interface has type arguments"); |
| 192 var barInterfaceTypeVariables = barInterface.typeVariables(); | 192 var barInterfaceTypeVariables = barInterface.typeVariables; |
| 193 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null"); | 193 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null"); |
| 194 Expect.isFalse(barInterfaceTypeVariables.isEmpty(), | 194 Expect.isFalse(barInterfaceTypeVariables.isEmpty(), |
| 195 "Type variable list is empty"); | 195 "Type variable list is empty"); |
| 196 Expect.equals(barInterfaceTypeVariables.length, 1, | 196 Expect.equals(barInterfaceTypeVariables.length, 1, |
| 197 "Unexpected number of type variables"); | 197 "Unexpected number of type variables"); |
| 198 | 198 |
| 199 var barE = barInterfaceTypeVariables[0]; | 199 var barE = barInterfaceTypeVariables[0]; |
| 200 Expect.isNotNull(barE, "Type variable is null"); | 200 Expect.isNotNull(barE, "Type variable is null"); |
| 201 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); | 201 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); |
| 202 | 202 |
| 203 Expect.isNull(barInterface.defaultType(), "Interface has default type"); | 203 Expect.isNull(barInterface.defaultType, "Interface has default type"); |
| 204 | 204 |
| 205 var barInterfaceMembers = barInterface.declaredMembers(); | 205 var barInterfaceMembers = barInterface.declaredMembers; |
| 206 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); | 206 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); |
| 207 Expect.isTrue(barInterfaceMembers.isEmpty(), | 207 Expect.isTrue(barInterfaceMembers.isEmpty(), |
| 208 "Declared members map is unempty"); | 208 "Declared members map is unempty"); |
| 209 | 209 |
| 210 var barInterfaceConstructors = barInterface.constructors(); | 210 var barInterfaceConstructors = barInterface.constructors; |
| 211 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); | 211 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); |
| 212 Expect.isTrue(barInterfaceConstructors.isEmpty(), | 212 Expect.isTrue(barInterfaceConstructors.isEmpty(), |
| 213 "Constructors map is unempty"); | 213 "Constructors map is unempty"); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Testing class Baz: | 216 // Testing class Baz: |
| 217 // | 217 // |
| 218 // class Baz<E,F extends Foo> implements Bar<E> { | 218 // class Baz<E,F extends Foo> implements Bar<E> { |
| 219 // Baz(); | 219 // Baz(); |
| 220 // const Baz.named(); | 220 // const Baz.named(); |
| 221 // factory Baz.factory(); | 221 // factory Baz.factory(); |
| 222 // | 222 // |
| 223 // method1(e) {} | 223 // method1(e) {} |
| 224 // static void method2(E e, [F f = null]) {} | 224 // static void method2(E e, [F f = null]) {} |
| 225 // void method3(E func1(F f), Func<E,F> func2) {} | 225 // void method3(E func1(F f), Func<E,F> func2) {} |
| 226 // | 226 // |
| 227 // bool operator==(Object other) => return false; | 227 // bool operator==(Object other) => return false; |
| 228 // Baz<E,F> operator negate() => this; | 228 // Baz<E,F> operator negate() => this; |
| 229 // } | 229 // } |
| 230 void testBaz(MirrorSystem system, LibraryMirror helperLibrary, | 230 void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
| 231 Map<Object,TypeMirror> types) { | 231 Map<Object,TypeMirror> types) { |
| 232 var bazClass = findMirror(types, "Baz"); | 232 var bazClass = findMirror(types, "Baz"); |
| 233 Expect.isNotNull(bazClass, "Type 'Baz' not found"); | 233 Expect.isNotNull(bazClass, "Type 'Baz' not found"); |
| 234 Expect.isTrue(bazClass is InterfaceMirror, | 234 Expect.isTrue(bazClass is InterfaceMirror, |
| 235 "Unexpected mirror type returned"); | 235 "Unexpected mirror type returned"); |
| 236 Expect.stringEquals("Baz", bazClass.simpleName(), | 236 Expect.stringEquals("Baz", bazClass.simpleName, |
| 237 "Unexpected type simple name"); | 237 "Unexpected type simple name"); |
| 238 Expect.stringEquals("mirrors_helper.Baz", bazClass.qualifiedName(), | 238 Expect.stringEquals("mirrors_helper.Baz", bazClass.qualifiedName, |
| 239 "Unexpected type qualified name"); | 239 "Unexpected type qualified name"); |
| 240 | 240 |
| 241 Expect.equals(helperLibrary, bazClass.library(), | 241 Expect.equals(helperLibrary, bazClass.library, |
| 242 "Unexpected library returned from type"); | 242 "Unexpected library returned from type"); |
| 243 | 243 |
| 244 Expect.isFalse(bazClass.isObject, "Class is Object"); | 244 Expect.isFalse(bazClass.isObject, "Class is Object"); |
| 245 Expect.isFalse(bazClass.isDynamic, "Class is Dynamic"); | 245 Expect.isFalse(bazClass.isDynamic, "Class is Dynamic"); |
| 246 Expect.isFalse(bazClass.isVoid, "Class is void"); | 246 Expect.isFalse(bazClass.isVoid, "Class is void"); |
| 247 Expect.isFalse(bazClass.isTypeVariable, "Class is a type variable"); | 247 Expect.isFalse(bazClass.isTypeVariable, "Class is a type variable"); |
| 248 Expect.isFalse(bazClass.isTypedef, "Class is a typedef"); | 248 Expect.isFalse(bazClass.isTypedef, "Class is a typedef"); |
| 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 objectType = bazClass.superclass(); | 259 var objectType = bazClass.superclass; |
| 260 Expect.isNotNull(objectType, "Superclass is null"); | 260 Expect.isNotNull(objectType, "Superclass is null"); |
| 261 Expect.isTrue(objectType.isObject, "Object is not Object"); | 261 Expect.isTrue(objectType.isObject, "Object is not Object"); |
| 262 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); | 262 Expect.isFalse(objectType.isDeclaration, "Object type is declaration"); |
| 263 Expect.isTrue(containsType(bazClass, | 263 Expect.isTrue(containsType(bazClass, |
| 264 computeSubdeclarations(objectType)), | 264 computeSubdeclarations(objectType)), |
| 265 "Class is not subclass of superclass"); | 265 "Class is not subclass of superclass"); |
| 266 | 266 |
| 267 var bazInterfaces = bazClass.interfaces(); | 267 var bazInterfaces = bazClass.interfaces; |
| 268 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); | 268 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); |
| 269 Expect.isTrue(!bazInterfaces.isEmpty(), "Interfaces map is empty"); | 269 Expect.isTrue(!bazInterfaces.isEmpty(), "Interfaces map is empty"); |
| 270 for (var bazInterface in bazInterfaces.getValues()) { | 270 for (var bazInterface in bazInterfaces.getValues()) { |
| 271 Expect.isTrue(containsType(bazClass, | 271 Expect.isTrue(containsType(bazClass, |
| 272 computeSubdeclarations(objectType)), | 272 computeSubdeclarations(objectType)), |
| 273 "Class is not subclass of superinterface"); | 273 "Class is not subclass of superinterface"); |
| 274 } | 274 } |
| 275 | 275 |
| 276 var bazSubdeclarations = computeSubdeclarations(bazClass); | 276 var bazSubdeclarations = computeSubdeclarations(bazClass); |
| 277 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); | 277 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); |
| 278 | 278 |
| 279 var barInterface = findMirror(bazInterfaces, "Bar"); | 279 var barInterface = findMirror(bazInterfaces, "Bar"); |
| 280 Expect.isNotNull(barInterface, "Interface bar is missing"); | 280 Expect.isNotNull(barInterface, "Interface bar is missing"); |
| 281 Expect.isFalse(barInterface.isDeclaration, "Interface type is declaration"); | 281 Expect.isFalse(barInterface.isDeclaration, "Interface type is declaration"); |
| 282 var barInterfaceTypeArguments = barInterface.typeArguments(); | 282 var barInterfaceTypeArguments = barInterface.typeArguments; |
| 283 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); | 283 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); |
| 284 Expect.equals(1, barInterfaceTypeArguments.length, | 284 Expect.equals(1, barInterfaceTypeArguments.length, |
| 285 "Type arguments is empty"); | 285 "Type arguments is empty"); |
| 286 | 286 |
| 287 Expect.throws(() => bazClass.typeArguments(), | 287 Expect.throws(() => bazClass.typeArguments, |
| 288 (exception) => true, | 288 (exception) => true, |
| 289 "Class has type arguments"); | 289 "Class has type arguments"); |
| 290 var bazClassTypeVariables = bazClass.typeVariables(); | 290 var bazClassTypeVariables = bazClass.typeVariables; |
| 291 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null"); | 291 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null"); |
| 292 Expect.equals(2, bazClassTypeVariables.length, | 292 Expect.equals(2, bazClassTypeVariables.length, |
| 293 "Type variable list is not empty"); | 293 "Type variable list is not empty"); |
| 294 | 294 |
| 295 var bazE = bazClassTypeVariables[0]; | 295 var bazE = bazClassTypeVariables[0]; |
| 296 Expect.isNotNull(bazE, "Type variable is null"); | 296 Expect.isNotNull(bazE, "Type variable is null"); |
| 297 Expect.stringEquals('E', bazE.simpleName(), "Unexpected simpleName"); | 297 Expect.stringEquals('E', bazE.simpleName, "Unexpected simpleName"); |
| 298 Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName(), | 298 Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName, |
| 299 "Unexpected qualifiedName"); | 299 "Unexpected qualifiedName"); |
| 300 Expect.equals(bazClass, bazE.declarer(), | 300 Expect.equals(bazClass, bazE.declarer, |
| 301 "Unexpected type variable declarer"); | 301 "Unexpected type variable declarer"); |
| 302 var bazEbound = bazE.bound(); | 302 var bazEbound = bazE.bound; |
| 303 Expect.isNotNull(bazEbound, "Missing type variable bound"); | 303 Expect.isNotNull(bazEbound, "Missing type variable bound"); |
| 304 Expect.isFalse(bazEbound.isDeclaration, "Bound is declaration"); | 304 Expect.isFalse(bazEbound.isDeclaration, "Bound is declaration"); |
| 305 Expect.isTrue(bazEbound.isObject, "Bound is not object"); | 305 Expect.isTrue(bazEbound.isObject, "Bound is not object"); |
| 306 | 306 |
| 307 var bazF = bazClassTypeVariables[1]; | 307 var bazF = bazClassTypeVariables[1]; |
| 308 Expect.isNotNull(bazF, "Type variable is null"); | 308 Expect.isNotNull(bazF, "Type variable is null"); |
| 309 Expect.stringEquals('F', bazF.simpleName(), "Unexpected simpleName"); | 309 Expect.stringEquals('F', bazF.simpleName, "Unexpected simpleName"); |
| 310 Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName(), | 310 Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName, |
| 311 "Unexpected qualifiedName"); | 311 "Unexpected qualifiedName"); |
| 312 Expect.equals(bazClass, bazF.declarer()); | 312 Expect.equals(bazClass, bazF.declarer); |
| 313 var bazFbound = bazF.bound(); | 313 var bazFbound = bazF.bound; |
| 314 Expect.isNotNull(bazFbound, "Missing type variable bound"); | 314 Expect.isNotNull(bazFbound, "Missing type variable bound"); |
| 315 Expect.isFalse(bazFbound.isDeclaration, "Bound is declaration"); | 315 Expect.isFalse(bazFbound.isDeclaration, "Bound is declaration"); |
| 316 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName(), | 316 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName, |
| 317 "Bound is not Foo"); | 317 "Bound is not Foo"); |
| 318 | 318 |
| 319 Expect.isNull(bazClass.defaultType(), "Class has default type"); | 319 Expect.isNull(bazClass.defaultType, "Class has default type"); |
| 320 | 320 |
| 321 var bazClassMembers = bazClass.declaredMembers(); | 321 var bazClassMembers = bazClass.declaredMembers; |
| 322 Expect.isNotNull(bazClassMembers, "Declared members map is null"); | 322 Expect.isNotNull(bazClassMembers, "Declared members map is null"); |
| 323 Expect.equals(8, bazClassMembers.length, | 323 Expect.equals(8, bazClassMembers.length, |
| 324 "Unexpected number of declared members"); | 324 "Unexpected number of declared members"); |
| 325 | 325 |
| 326 //////////////////////////////////////////////////////////////////////////// | 326 //////////////////////////////////////////////////////////////////////////// |
| 327 // method1(e) {} | 327 // method1(e) {} |
| 328 //////////////////////////////////////////////////////////////////////////// | 328 //////////////////////////////////////////////////////////////////////////// |
| 329 var method1 = findMirror(bazClassMembers, "method1"); | 329 var method1 = findMirror(bazClassMembers, "method1"); |
| 330 Expect.isNotNull(method1, "method1 not found"); | 330 Expect.isNotNull(method1, "method1 not found"); |
| 331 Expect.stringEquals('method1', method1.simpleName(), | 331 Expect.stringEquals('method1', method1.simpleName, |
| 332 "Unexpected method simpleName"); | 332 "Unexpected method simpleName"); |
| 333 Expect.stringEquals('mirrors_helper.Baz.method1', method1.qualifiedName(), | 333 Expect.stringEquals('mirrors_helper.Baz.method1', method1.qualifiedName, |
| 334 "Unexpected method qualifiedName"); | 334 "Unexpected method qualifiedName"); |
| 335 Expect.equals(method1.surroundingDeclaration(), bazClass, | 335 Expect.equals(method1.surroundingDeclaration, bazClass, |
| 336 "Unexpected surrounding declaration"); | 336 "Unexpected surrounding declaration"); |
| 337 Expect.isFalse(method1.isTopLevel, "Method is top level"); | 337 Expect.isFalse(method1.isTopLevel, "Method is top level"); |
| 338 Expect.isFalse(method1.isConstructor, "Method is constructor"); | 338 Expect.isFalse(method1.isConstructor, "Method is constructor"); |
| 339 Expect.isFalse(method1.isField, "Method is field"); | 339 Expect.isFalse(method1.isField, "Method is field"); |
| 340 Expect.isTrue(method1.isMethod, "Method is not method"); | 340 Expect.isTrue(method1.isMethod, "Method is not method"); |
| 341 Expect.isFalse(method1.isPrivate, "Method is private"); | 341 Expect.isFalse(method1.isPrivate, "Method is private"); |
| 342 Expect.isFalse(method1.isStatic, "Method is static"); | 342 Expect.isFalse(method1.isStatic, "Method is static"); |
| 343 Expect.isTrue(method1 is MethodMirror, "Method is not MethodMirror"); | 343 Expect.isTrue(method1 is MethodMirror, "Method is not MethodMirror"); |
| 344 Expect.isFalse(method1.isConst, "Method is const"); | 344 Expect.isFalse(method1.isConst, "Method is const"); |
| 345 Expect.isFalse(method1.isFactory, "Method is factory"); | 345 Expect.isFalse(method1.isFactory, "Method is factory"); |
| 346 Expect.isNull(method1.constructorName, | 346 Expect.isNull(method1.constructorName, |
| 347 "Method constructorName is non-null"); | 347 "Method constructorName is non-null"); |
| 348 Expect.isFalse(method1.isGetter, "Method is getter"); | 348 Expect.isFalse(method1.isGetter, "Method is getter"); |
| 349 Expect.isFalse(method1.isSetter, "Method is setter"); | 349 Expect.isFalse(method1.isSetter, "Method is setter"); |
| 350 Expect.isFalse(method1.isOperator, "Method is operator"); | 350 Expect.isFalse(method1.isOperator, "Method is operator"); |
| 351 Expect.isNull(method1.operatorName, | 351 Expect.isNull(method1.operatorName, |
| 352 "Method operatorName is non-null"); | 352 "Method operatorName is non-null"); |
| 353 | 353 |
| 354 var dynamicType = method1.returnType(); | 354 var dynamicType = method1.returnType; |
| 355 Expect.isNotNull(dynamicType, "Return type was null"); | 355 Expect.isNotNull(dynamicType, "Return type was null"); |
| 356 Expect.isFalse(dynamicType.isObject, "Dynamic is Object"); | 356 Expect.isFalse(dynamicType.isObject, "Dynamic is Object"); |
| 357 Expect.isTrue(dynamicType.isDynamic, "Dynamic is not Dynamic"); | 357 Expect.isTrue(dynamicType.isDynamic, "Dynamic is not Dynamic"); |
| 358 Expect.isFalse(dynamicType.isVoid, "Dynamic is void"); | 358 Expect.isFalse(dynamicType.isVoid, "Dynamic is void"); |
| 359 Expect.isFalse(dynamicType.isTypeVariable, "Dynamic is a type variable"); | 359 Expect.isFalse(dynamicType.isTypeVariable, "Dynamic is a type variable"); |
| 360 Expect.isFalse(dynamicType.isTypedef, "Dynamic is a typedef"); | 360 Expect.isFalse(dynamicType.isTypedef, "Dynamic is a typedef"); |
| 361 Expect.isFalse(dynamicType.isFunction, "Dynamic is a function"); | 361 Expect.isFalse(dynamicType.isFunction, "Dynamic is a function"); |
| 362 | 362 |
| 363 var method1Parameters = method1.parameters(); | 363 var method1Parameters = method1.parameters; |
| 364 Expect.isNotNull(method1Parameters, "Method parameters is null"); | 364 Expect.isNotNull(method1Parameters, "Method parameters is null"); |
| 365 Expect.equals(1, method1Parameters.length, "Unexpected parameter count"); | 365 Expect.equals(1, method1Parameters.length, "Unexpected parameter count"); |
| 366 var method1Parameter1 = method1Parameters[0]; | 366 var method1Parameter1 = method1Parameters[0]; |
| 367 Expect.isNotNull(method1Parameter1, "Parameter is null"); | 367 Expect.isNotNull(method1Parameter1, "Parameter is null"); |
| 368 Expect.equals(dynamicType, method1Parameter1.type()); | 368 Expect.equals(dynamicType, method1Parameter1.type); |
| 369 Expect.stringEquals("e", method1Parameter1.simpleName(), | 369 Expect.stringEquals("e", method1Parameter1.simpleName, |
| 370 "Unexpected parameter simpleName"); | 370 "Unexpected parameter simpleName"); |
| 371 Expect.stringEquals("mirrors_helper.Baz.method1#e", | 371 Expect.stringEquals("mirrors_helper.Baz.method1#e", |
| 372 method1Parameter1.qualifiedName(), | 372 method1Parameter1.qualifiedName, |
| 373 "Unexpected parameter qualifiedName"); | 373 "Unexpected parameter qualifiedName"); |
| 374 Expect.isFalse(method1Parameter1.hasDefaultValue(), | 374 Expect.isFalse(method1Parameter1.hasDefaultValue, |
| 375 "Parameter has default value"); | 375 "Parameter has default value"); |
| 376 Expect.isNull(method1Parameter1.defaultValue(), | 376 Expect.isNull(method1Parameter1.defaultValue, |
| 377 "Parameter default value is non-null"); | 377 "Parameter default value is non-null"); |
| 378 Expect.isFalse(method1Parameter1.isOptional(), "Parameter is optional"); | 378 Expect.isFalse(method1Parameter1.isOptional, "Parameter is optional"); |
| 379 | 379 |
| 380 //////////////////////////////////////////////////////////////////////////// | 380 //////////////////////////////////////////////////////////////////////////// |
| 381 // static void method2(E e, [F f = null]) {} | 381 // static void method2(E e, [F f = null]) {} |
| 382 //////////////////////////////////////////////////////////////////////////// | 382 //////////////////////////////////////////////////////////////////////////// |
| 383 var method2 = findMirror(bazClassMembers, "method2"); | 383 var method2 = findMirror(bazClassMembers, "method2"); |
| 384 Expect.isNotNull(method2, "method2 not found"); | 384 Expect.isNotNull(method2, "method2 not found"); |
| 385 Expect.stringEquals('method2', method2.simpleName(), | 385 Expect.stringEquals('method2', method2.simpleName, |
| 386 "Unexpected method simpleName"); | 386 "Unexpected method simpleName"); |
| 387 Expect.stringEquals('mirrors_helper.Baz.method2', method2.qualifiedName(), | 387 Expect.stringEquals('mirrors_helper.Baz.method2', method2.qualifiedName, |
| 388 "Unexpected method qualifiedName"); | 388 "Unexpected method qualifiedName"); |
| 389 Expect.equals(method2.surroundingDeclaration(), bazClass, | 389 Expect.equals(method2.surroundingDeclaration, bazClass, |
| 390 "Unexpected surrounding declaration"); | 390 "Unexpected surrounding declaration"); |
| 391 Expect.isFalse(method2.isTopLevel, "Method is top level"); | 391 Expect.isFalse(method2.isTopLevel, "Method is top level"); |
| 392 Expect.isFalse(method2.isConstructor, "Method is constructor"); | 392 Expect.isFalse(method2.isConstructor, "Method is constructor"); |
| 393 Expect.isFalse(method2.isField, "Method is field"); | 393 Expect.isFalse(method2.isField, "Method is field"); |
| 394 Expect.isTrue(method2.isMethod, "Method is not method"); | 394 Expect.isTrue(method2.isMethod, "Method is not method"); |
| 395 Expect.isFalse(method2.isPrivate, "Method is private"); | 395 Expect.isFalse(method2.isPrivate, "Method is private"); |
| 396 Expect.isTrue(method2.isStatic, "Method is not static"); | 396 Expect.isTrue(method2.isStatic, "Method is not static"); |
| 397 Expect.isTrue(method2 is MethodMirror, "Method is not MethodMirror"); | 397 Expect.isTrue(method2 is MethodMirror, "Method is not MethodMirror"); |
| 398 Expect.isFalse(method2.isConst, "Method is const"); | 398 Expect.isFalse(method2.isConst, "Method is const"); |
| 399 Expect.isFalse(method2.isFactory, "Method is factory"); | 399 Expect.isFalse(method2.isFactory, "Method is factory"); |
| 400 Expect.isNull(method2.constructorName, | 400 Expect.isNull(method2.constructorName, |
| 401 "Method constructorName is non-null"); | 401 "Method constructorName is non-null"); |
| 402 Expect.isFalse(method2.isGetter, "Method is getter"); | 402 Expect.isFalse(method2.isGetter, "Method is getter"); |
| 403 Expect.isFalse(method2.isSetter, "Method is setter"); | 403 Expect.isFalse(method2.isSetter, "Method is setter"); |
| 404 Expect.isFalse(method2.isOperator, "Method is operator"); | 404 Expect.isFalse(method2.isOperator, "Method is operator"); |
| 405 Expect.isNull(method2.operatorName, | 405 Expect.isNull(method2.operatorName, |
| 406 "Method operatorName is non-null"); | 406 "Method operatorName is non-null"); |
| 407 | 407 |
| 408 var voidType = method2.returnType(); | 408 var voidType = method2.returnType; |
| 409 Expect.isNotNull(voidType, "Return type was null"); | 409 Expect.isNotNull(voidType, "Return type was null"); |
| 410 Expect.isFalse(voidType.isObject, "void is Object"); | 410 Expect.isFalse(voidType.isObject, "void is Object"); |
| 411 Expect.isFalse(voidType.isDynamic, "void is Dynamic"); | 411 Expect.isFalse(voidType.isDynamic, "void is Dynamic"); |
| 412 Expect.isTrue(voidType.isVoid, "void is not void"); | 412 Expect.isTrue(voidType.isVoid, "void is not void"); |
| 413 Expect.isFalse(voidType.isTypeVariable, "void is a type variable"); | 413 Expect.isFalse(voidType.isTypeVariable, "void is a type variable"); |
| 414 Expect.isFalse(voidType.isTypedef, "void is a typedef"); | 414 Expect.isFalse(voidType.isTypedef, "void is a typedef"); |
| 415 Expect.isFalse(voidType.isFunction, "void is a function"); | 415 Expect.isFalse(voidType.isFunction, "void is a function"); |
| 416 | 416 |
| 417 var method2Parameters = method2.parameters(); | 417 var method2Parameters = method2.parameters; |
| 418 Expect.isNotNull(method2Parameters, "Method parameters is null"); | 418 Expect.isNotNull(method2Parameters, "Method parameters is null"); |
| 419 Expect.equals(2, method2Parameters.length, "Unexpected parameter count"); | 419 Expect.equals(2, method2Parameters.length, "Unexpected parameter count"); |
| 420 var method2Parameter1 = method2Parameters[0]; | 420 var method2Parameter1 = method2Parameters[0]; |
| 421 Expect.isNotNull(method2Parameter1, "Parameter is null"); | 421 Expect.isNotNull(method2Parameter1, "Parameter is null"); |
| 422 Expect.equals(bazE, method2Parameter1.type()); | 422 Expect.equals(bazE, method2Parameter1.type); |
| 423 Expect.stringEquals("e", method2Parameter1.simpleName(), | 423 Expect.stringEquals("e", method2Parameter1.simpleName, |
| 424 "Unexpected parameter simpleName"); | 424 "Unexpected parameter simpleName"); |
| 425 Expect.stringEquals("mirrors_helper.Baz.method2#e", | 425 Expect.stringEquals("mirrors_helper.Baz.method2#e", |
| 426 method2Parameter1.qualifiedName(), | 426 method2Parameter1.qualifiedName, |
| 427 "Unexpected parameter qualifiedName"); | 427 "Unexpected parameter qualifiedName"); |
| 428 Expect.isFalse(method2Parameter1.hasDefaultValue(), | 428 Expect.isFalse(method2Parameter1.hasDefaultValue, |
| 429 "Parameter has default value"); | 429 "Parameter has default value"); |
| 430 Expect.isNull(method2Parameter1.defaultValue(), | 430 Expect.isNull(method2Parameter1.defaultValue, |
| 431 "Parameter default value is non-null"); | 431 "Parameter default value is non-null"); |
| 432 Expect.isFalse(method2Parameter1.isOptional(), "Parameter is optional"); | 432 Expect.isFalse(method2Parameter1.isOptional, "Parameter is optional"); |
| 433 var method2Parameter2 = method2Parameters[1]; | 433 var method2Parameter2 = method2Parameters[1]; |
| 434 Expect.isNotNull(method2Parameter2, "Parameter is null"); | 434 Expect.isNotNull(method2Parameter2, "Parameter is null"); |
| 435 Expect.equals(bazF, method2Parameter2.type()); | 435 Expect.equals(bazF, method2Parameter2.type); |
| 436 Expect.stringEquals("f", method2Parameter2.simpleName(), | 436 Expect.stringEquals("f", method2Parameter2.simpleName, |
| 437 "Unexpected parameter simpleName"); | 437 "Unexpected parameter simpleName"); |
| 438 Expect.stringEquals("mirrors_helper.Baz.method2#f", | 438 Expect.stringEquals("mirrors_helper.Baz.method2#f", |
| 439 method2Parameter2.qualifiedName(), | 439 method2Parameter2.qualifiedName, |
| 440 "Unexpected parameter qualifiedName"); | 440 "Unexpected parameter qualifiedName"); |
| 441 Expect.isTrue(method2Parameter2.hasDefaultValue(), | 441 Expect.isTrue(method2Parameter2.hasDefaultValue, |
| 442 "Parameter has default value"); | 442 "Parameter has default value"); |
| 443 Expect.stringEquals("null", method2Parameter2.defaultValue(), | 443 Expect.stringEquals("null", method2Parameter2.defaultValue, |
| 444 "Parameter default value is non-null"); | 444 "Parameter default value is non-null"); |
| 445 Expect.isTrue(method2Parameter2.isOptional(), "Parameter is not optional"); | 445 Expect.isTrue(method2Parameter2.isOptional, "Parameter is not optional"); |
| 446 | 446 |
| 447 //////////////////////////////////////////////////////////////////////////// | 447 //////////////////////////////////////////////////////////////////////////// |
| 448 // void method3(E func1(F f), Func<E,F> func2) {} | 448 // void method3(E func1(F f), Func<E,F> func2) {} |
| 449 //////////////////////////////////////////////////////////////////////////// | 449 //////////////////////////////////////////////////////////////////////////// |
| 450 var method3 = findMirror(bazClassMembers, "method3"); | 450 var method3 = findMirror(bazClassMembers, "method3"); |
| 451 Expect.isNotNull(method3, "method3 not found"); | 451 Expect.isNotNull(method3, "method3 not found"); |
| 452 Expect.stringEquals('method3', method3.simpleName(), | 452 Expect.stringEquals('method3', method3.simpleName, |
| 453 "Unexpected method simpleName"); | 453 "Unexpected method simpleName"); |
| 454 Expect.stringEquals('mirrors_helper.Baz.method3', method3.qualifiedName(), | 454 Expect.stringEquals('mirrors_helper.Baz.method3', method3.qualifiedName, |
| 455 "Unexpected method qualifiedName"); | 455 "Unexpected method qualifiedName"); |
| 456 Expect.equals(method3.surroundingDeclaration(), bazClass, | 456 Expect.equals(method3.surroundingDeclaration, bazClass, |
| 457 "Unexpected surrounding declaration"); | 457 "Unexpected surrounding declaration"); |
| 458 Expect.isFalse(method3.isTopLevel, "Method is top level"); | 458 Expect.isFalse(method3.isTopLevel, "Method is top level"); |
| 459 Expect.isFalse(method3.isConstructor, "Method is constructor"); | 459 Expect.isFalse(method3.isConstructor, "Method is constructor"); |
| 460 Expect.isFalse(method3.isField, "Method is field"); | 460 Expect.isFalse(method3.isField, "Method is field"); |
| 461 Expect.isTrue(method3.isMethod, "Method is not method"); | 461 Expect.isTrue(method3.isMethod, "Method is not method"); |
| 462 Expect.isFalse(method3.isPrivate, "Method is private"); | 462 Expect.isFalse(method3.isPrivate, "Method is private"); |
| 463 Expect.isFalse(method3.isStatic, "Method is static"); | 463 Expect.isFalse(method3.isStatic, "Method is static"); |
| 464 Expect.isTrue(method3 is MethodMirror, "Method is not MethodMirror"); | 464 Expect.isTrue(method3 is MethodMirror, "Method is not MethodMirror"); |
| 465 Expect.isFalse(method3.isConst, "Method is const"); | 465 Expect.isFalse(method3.isConst, "Method is const"); |
| 466 Expect.isFalse(method3.isFactory, "Method is factory"); | 466 Expect.isFalse(method3.isFactory, "Method is factory"); |
| 467 Expect.isNull(method3.constructorName, | 467 Expect.isNull(method3.constructorName, |
| 468 "Method constructorName is non-null"); | 468 "Method constructorName is non-null"); |
| 469 Expect.isFalse(method3.isGetter, "Method is getter"); | 469 Expect.isFalse(method3.isGetter, "Method is getter"); |
| 470 Expect.isFalse(method3.isSetter, "Method is setter"); | 470 Expect.isFalse(method3.isSetter, "Method is setter"); |
| 471 Expect.isFalse(method3.isOperator, "Method is operator"); | 471 Expect.isFalse(method3.isOperator, "Method is operator"); |
| 472 Expect.isNull(method3.operatorName, | 472 Expect.isNull(method3.operatorName, |
| 473 "Method operatorName is non-null"); | 473 "Method operatorName is non-null"); |
| 474 | 474 |
| 475 Expect.equals(voidType, method3.returnType(), "Return type is not void"); | 475 Expect.equals(voidType, method3.returnType, "Return type is not void"); |
| 476 | 476 |
| 477 var method3Parameters = method3.parameters(); | 477 var method3Parameters = method3.parameters; |
| 478 Expect.isNotNull(method3Parameters, "Method parameters is null"); | 478 Expect.isNotNull(method3Parameters, "Method parameters is null"); |
| 479 Expect.equals(2, method3Parameters.length, "Unexpected parameter count"); | 479 Expect.equals(2, method3Parameters.length, "Unexpected parameter count"); |
| 480 var method3Parameter1 = method3Parameters[0]; | 480 var method3Parameter1 = method3Parameters[0]; |
| 481 Expect.isNotNull(method3Parameter1, "Parameter is null"); | 481 Expect.isNotNull(method3Parameter1, "Parameter is null"); |
| 482 var method3Parameter1type = method3Parameter1.type(); | 482 var method3Parameter1type = method3Parameter1.type; |
| 483 Expect.isNotNull(method3Parameter1type, "Parameter type of 'func1' is null"); | 483 Expect.isNotNull(method3Parameter1type, "Parameter type of 'func1' is null"); |
| 484 Expect.isTrue(method3Parameter1type is FunctionTypeMirror, | 484 Expect.isTrue(method3Parameter1type is FunctionTypeMirror, |
| 485 "Parameter type of 'func1' is not a function"); | 485 "Parameter type of 'func1' is not a function"); |
| 486 Expect.equals(bazE, method3Parameter1type.returnType(), | 486 Expect.equals(bazE, method3Parameter1type.returnType, |
| 487 "Return type of 'func1' is not a E"); | 487 "Return type of 'func1' is not a E"); |
| 488 Expect.isNotNull(method3Parameter1type.parameters(), | 488 Expect.isNotNull(method3Parameter1type.parameters, |
| 489 "Parameters of 'func1' is null"); | 489 "Parameters of 'func1' is null"); |
| 490 Expect.equals(1, method3Parameter1type.parameters().length, | 490 Expect.equals(1, method3Parameter1type.parameters.length, |
| 491 "Unexpected parameter count of 'func1'"); | 491 "Unexpected parameter count of 'func1'"); |
| 492 Expect.equals(bazE, method3Parameter1type.returnType(), | 492 Expect.equals(bazE, method3Parameter1type.returnType, |
| 493 "Return type of 'func1' is not a E"); | 493 "Return type of 'func1' is not a E"); |
| 494 Expect.isNotNull(method3Parameter1type.parameters()[0], | 494 Expect.isNotNull(method3Parameter1type.parameters[0], |
| 495 "Parameter 1 of 'func1' is null"); | 495 "Parameter 1 of 'func1' is null"); |
| 496 Expect.stringEquals('f', method3Parameter1type.parameters()[0].simpleName(), | 496 Expect.stringEquals('f', method3Parameter1type.parameters[0].simpleName, |
| 497 "Unexpected name parameter 1 of 'func1'"); | 497 "Unexpected name parameter 1 of 'func1'"); |
| 498 Expect.equals(bazF, method3Parameter1type.parameters()[0].type(), | 498 Expect.equals(bazF, method3Parameter1type.parameters[0].type, |
| 499 "Argument type of 'func1' is not a F"); | 499 "Argument type of 'func1' is not a F"); |
| 500 Expect.stringEquals("func1", method3Parameter1.simpleName(), | 500 Expect.stringEquals("func1", method3Parameter1.simpleName, |
| 501 "Unexpected parameter simpleName"); | 501 "Unexpected parameter simpleName"); |
| 502 Expect.stringEquals("mirrors_helper.Baz.method3#func1", | 502 Expect.stringEquals("mirrors_helper.Baz.method3#func1", |
| 503 method3Parameter1.qualifiedName(), | 503 method3Parameter1.qualifiedName, |
| 504 "Unexpected parameter qualifiedName"); | 504 "Unexpected parameter qualifiedName"); |
| 505 Expect.isFalse(method3Parameter1.hasDefaultValue(), | 505 Expect.isFalse(method3Parameter1.hasDefaultValue, |
| 506 "Parameter has default value"); | 506 "Parameter has default value"); |
| 507 Expect.isNull(method3Parameter1.defaultValue(), | 507 Expect.isNull(method3Parameter1.defaultValue, |
| 508 "Parameter default value is non-null"); | 508 "Parameter default value is non-null"); |
| 509 Expect.isFalse(method3Parameter1.isOptional(), "Parameter is optional"); | 509 Expect.isFalse(method3Parameter1.isOptional, "Parameter is optional"); |
| 510 | 510 |
| 511 var method3Parameter2 = method3Parameters[1]; | 511 var method3Parameter2 = method3Parameters[1]; |
| 512 Expect.isNotNull(method3Parameter2, "Parameter is null"); | 512 Expect.isNotNull(method3Parameter2, "Parameter is null"); |
| 513 var funcTypedef = method3Parameter2.type(); | 513 var funcTypedef = method3Parameter2.type; |
| 514 Expect.isNotNull(funcTypedef, "Parameter type is null"); | 514 Expect.isNotNull(funcTypedef, "Parameter type is null"); |
| 515 Expect.stringEquals("Func", funcTypedef.simpleName(), | 515 Expect.stringEquals("Func", funcTypedef.simpleName, |
| 516 "Unexpected simpleName"); | 516 "Unexpected simpleName"); |
| 517 Expect.stringEquals("mirrors_helper.Func", funcTypedef.qualifiedName(), | 517 Expect.stringEquals("mirrors_helper.Func", funcTypedef.qualifiedName, |
| 518 "Unexpected simpleName"); | 518 "Unexpected simpleName"); |
| 519 Expect.isFalse(funcTypedef.isObject, "Typedef is Object"); | 519 Expect.isFalse(funcTypedef.isObject, "Typedef is Object"); |
| 520 Expect.isFalse(funcTypedef.isDynamic, "Typedef is Dynamic"); | 520 Expect.isFalse(funcTypedef.isDynamic, "Typedef is Dynamic"); |
| 521 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); | 521 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); |
| 522 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); | 522 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); |
| 523 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); | 523 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); |
| 524 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); | 524 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); |
| 525 | 525 |
| 526 Expect.equals(helperLibrary, funcTypedef.library(), | 526 Expect.equals(helperLibrary, funcTypedef.library, |
| 527 "Unexpected typedef library"); | 527 "Unexpected typedef library"); |
| 528 Expect.isNull(funcTypedef.superclass(), "Non-null superclass on typedef"); | 528 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef"); |
| 529 Expect.isNotNull(funcTypedef.interfaces(), | 529 Expect.isNotNull(funcTypedef.interfaces, |
| 530 "Null interfaces map on typedef"); | 530 "Null interfaces map on typedef"); |
| 531 Expect.isTrue(funcTypedef.interfaces().isEmpty(), | 531 Expect.isTrue(funcTypedef.interfaces.isEmpty(), |
| 532 "Non-empty interfaces map on typedef"); | 532 "Non-empty interfaces map on typedef"); |
| 533 Expect.isNotNull(funcTypedef.declaredMembers(), | 533 Expect.isNotNull(funcTypedef.declaredMembers, |
| 534 "Declared members map is null on type def"); | 534 "Declared members map is null on type def"); |
| 535 Expect.isTrue(funcTypedef.declaredMembers().isEmpty(), | 535 Expect.isTrue(funcTypedef.declaredMembers.isEmpty(), |
| 536 "Non-empty declared members map on typedef"); | 536 "Non-empty declared members map on typedef"); |
| 537 | 537 |
| 538 // TODO(johnniwinther): Returned typedef should not be the declaration: | 538 // TODO(johnniwinther): Returned typedef should not be the declaration: |
| 539 Expect.isTrue(funcTypedef.isDeclaration, "Typedef is not declaration"); | 539 Expect.isTrue(funcTypedef.isDeclaration, "Typedef is not declaration"); |
| 540 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); | 540 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); |
| 541 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); | 541 Expect.isFalse(funcTypedef.isInterface, "Typedef is interface"); |
| 542 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); | 542 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); |
| 543 Expect.isNull(funcTypedef.defaultType(), | 543 Expect.isNull(funcTypedef.defaultType, |
| 544 "Typedef default type is non-null"); | 544 "Typedef default type is non-null"); |
| 545 // TODO(johnniwinther): Should not throw an exception since the type should | 545 // TODO(johnniwinther): Should not throw an exception since the type should |
| 546 // not be the declaration. | 546 // not be the declaration. |
| 547 Expect.throws(() => funcTypedef.typeArguments(), | 547 Expect.throws(() => funcTypedef.typeArguments, |
| 548 (exception) => true, | 548 (exception) => true, |
| 549 "Typedef has type arguments"); | 549 "Typedef has type arguments"); |
| 550 Expect.isNotNull(funcTypedef.typeVariables(), "Type variables is null"); | 550 Expect.isNotNull(funcTypedef.typeVariables, "Type variables is null"); |
| 551 // TODO(johnniwinther): Should return a non-empty map. | 551 // TODO(johnniwinther): Should return a non-empty map. |
| 552 Expect.isTrue(funcTypedef.typeVariables().isEmpty(), | 552 Expect.isTrue(funcTypedef.typeVariables.isEmpty(), |
| 553 "Type variables is non-empty"); | 553 "Type variables is non-empty"); |
| 554 // TODO(johnniwinther): Provide access to the definition type. | 554 // TODO(johnniwinther): Provide access to the definition type. |
| 555 Expect.isNull(funcTypedef.definition(), "Typedef definition is not null"); | 555 Expect.isNull(funcTypedef.definition, "Typedef definition is not null"); |
| 556 | 556 |
| 557 Expect.stringEquals("func2", method3Parameter2.simpleName(), | 557 Expect.stringEquals("func2", method3Parameter2.simpleName, |
| 558 "Unexpected parameter simpleName"); | 558 "Unexpected parameter simpleName"); |
| 559 Expect.stringEquals("mirrors_helper.Baz.method3#func2", | 559 Expect.stringEquals("mirrors_helper.Baz.method3#func2", |
| 560 method3Parameter2.qualifiedName(), | 560 method3Parameter2.qualifiedName, |
| 561 "Unexpected parameter qualifiedName"); | 561 "Unexpected parameter qualifiedName"); |
| 562 Expect.isFalse(method3Parameter2.hasDefaultValue(), | 562 Expect.isFalse(method3Parameter2.hasDefaultValue, |
| 563 "Parameter 'func2' has default value: " | 563 "Parameter 'func2' has default value: " |
| 564 "${method3Parameter2.defaultValue()}"); | 564 "${method3Parameter2.defaultValue}"); |
| 565 Expect.isNull(method3Parameter2.defaultValue(), | 565 Expect.isNull(method3Parameter2.defaultValue, |
| 566 "Parameter default value is non-null"); | 566 "Parameter default value is non-null"); |
| 567 Expect.isFalse(method3Parameter2.isOptional(), "Parameter is optional"); | 567 Expect.isFalse(method3Parameter2.isOptional, "Parameter is optional"); |
| 568 | 568 |
| 569 //////////////////////////////////////////////////////////////////////////// | 569 //////////////////////////////////////////////////////////////////////////// |
| 570 // bool operator==(Object other) => return false; | 570 // bool operator==(Object other) => return false; |
| 571 //////////////////////////////////////////////////////////////////////////// | 571 //////////////////////////////////////////////////////////////////////////// |
| 572 var operator_eq = findMirror(bazClassMembers, "operator", operatorName: '=='); | 572 var operator_eq = findMirror(bazClassMembers, "operator", operatorName: '=='); |
| 573 Expect.isNotNull(operator_eq, "operator == not found"); | 573 Expect.isNotNull(operator_eq, "operator == not found"); |
| 574 Expect.stringEquals('operator', operator_eq.simpleName(), | 574 Expect.stringEquals('operator', operator_eq.simpleName, |
| 575 "Unexpected method simpleName"); | 575 "Unexpected method simpleName"); |
| 576 Expect.stringEquals('mirrors_helper.Baz.operator ==', | 576 Expect.stringEquals('mirrors_helper.Baz.operator ==', |
| 577 operator_eq.qualifiedName(), | 577 operator_eq.qualifiedName, |
| 578 "Unexpected method qualifiedName"); | 578 "Unexpected method qualifiedName"); |
| 579 Expect.equals(operator_eq.surroundingDeclaration(), bazClass, | 579 Expect.equals(operator_eq.surroundingDeclaration, bazClass, |
| 580 "Unexpected surrounding declaration"); | 580 "Unexpected surrounding declaration"); |
| 581 Expect.isFalse(operator_eq.isTopLevel, "Method is top level"); | 581 Expect.isFalse(operator_eq.isTopLevel, "Method is top level"); |
| 582 Expect.isFalse(operator_eq.isConstructor, "Method is constructor"); | 582 Expect.isFalse(operator_eq.isConstructor, "Method is constructor"); |
| 583 Expect.isFalse(operator_eq.isField, "Method is field"); | 583 Expect.isFalse(operator_eq.isField, "Method is field"); |
| 584 Expect.isTrue(operator_eq.isMethod, "Method is not method"); | 584 Expect.isTrue(operator_eq.isMethod, "Method is not method"); |
| 585 Expect.isFalse(operator_eq.isPrivate, "Method is private"); | 585 Expect.isFalse(operator_eq.isPrivate, "Method is private"); |
| 586 Expect.isFalse(operator_eq.isStatic, "Method is static"); | 586 Expect.isFalse(operator_eq.isStatic, "Method is static"); |
| 587 Expect.isTrue(operator_eq is MethodMirror, "Method is not MethodMirror"); | 587 Expect.isTrue(operator_eq is MethodMirror, "Method is not MethodMirror"); |
| 588 Expect.isFalse(operator_eq.isConst, "Method is const"); | 588 Expect.isFalse(operator_eq.isConst, "Method is const"); |
| 589 Expect.isFalse(operator_eq.isFactory, "Method is factory"); | 589 Expect.isFalse(operator_eq.isFactory, "Method is factory"); |
| 590 Expect.isNull(operator_eq.constructorName, | 590 Expect.isNull(operator_eq.constructorName, |
| 591 "Method constructorName is non-null"); | 591 "Method constructorName is non-null"); |
| 592 Expect.isFalse(operator_eq.isGetter, "Method is getter"); | 592 Expect.isFalse(operator_eq.isGetter, "Method is getter"); |
| 593 Expect.isFalse(operator_eq.isSetter, "Method is setter"); | 593 Expect.isFalse(operator_eq.isSetter, "Method is setter"); |
| 594 Expect.isTrue(operator_eq.isOperator, "Method is not operator"); | 594 Expect.isTrue(operator_eq.isOperator, "Method is not operator"); |
| 595 Expect.stringEquals('==', operator_eq.operatorName, | 595 Expect.stringEquals('==', operator_eq.operatorName, |
| 596 "Unexpected operatorName"); | 596 "Unexpected operatorName"); |
| 597 | 597 |
| 598 //////////////////////////////////////////////////////////////////////////// | 598 //////////////////////////////////////////////////////////////////////////// |
| 599 // Baz<E,F> operator negate() => this; | 599 // Baz<E,F> operator negate() => this; |
| 600 //////////////////////////////////////////////////////////////////////////// | 600 //////////////////////////////////////////////////////////////////////////// |
| 601 var operator_negate = findMirror(bazClassMembers, "operator", | 601 var operator_negate = findMirror(bazClassMembers, "operator", |
| 602 operatorName: 'negate'); | 602 operatorName: 'negate'); |
| 603 Expect.isNotNull(operator_negate, "operator < not found"); | 603 Expect.isNotNull(operator_negate, "operator < not found"); |
| 604 Expect.stringEquals('operator', operator_negate.simpleName(), | 604 Expect.stringEquals('operator', operator_negate.simpleName, |
| 605 "Unexpected method simpleName"); | 605 "Unexpected method simpleName"); |
| 606 Expect.stringEquals('mirrors_helper.Baz.operator negate', | 606 Expect.stringEquals('mirrors_helper.Baz.operator negate', |
| 607 operator_negate.qualifiedName(), | 607 operator_negate.qualifiedName, |
| 608 "Unexpected method qualifiedName"); | 608 "Unexpected method qualifiedName"); |
| 609 Expect.equals(operator_negate.surroundingDeclaration(), bazClass, | 609 Expect.equals(operator_negate.surroundingDeclaration, bazClass, |
| 610 "Unexpected surrounding declaration"); | 610 "Unexpected surrounding declaration"); |
| 611 Expect.isFalse(operator_negate.isTopLevel, "Method is top level"); | 611 Expect.isFalse(operator_negate.isTopLevel, "Method is top level"); |
| 612 Expect.isFalse(operator_negate.isConstructor, "Method is constructor"); | 612 Expect.isFalse(operator_negate.isConstructor, "Method is constructor"); |
| 613 Expect.isFalse(operator_negate.isField, "Method is field"); | 613 Expect.isFalse(operator_negate.isField, "Method is field"); |
| 614 Expect.isTrue(operator_negate.isMethod, "Method is not method"); | 614 Expect.isTrue(operator_negate.isMethod, "Method is not method"); |
| 615 Expect.isFalse(operator_negate.isPrivate, "Method is private"); | 615 Expect.isFalse(operator_negate.isPrivate, "Method is private"); |
| 616 Expect.isFalse(operator_negate.isStatic, "Method is static"); | 616 Expect.isFalse(operator_negate.isStatic, "Method is static"); |
| 617 Expect.isTrue(operator_negate is MethodMirror, | 617 Expect.isTrue(operator_negate is MethodMirror, |
| 618 "Method is not MethodMirror"); | 618 "Method is not MethodMirror"); |
| 619 Expect.isFalse(operator_negate.isConst, "Method is const"); | 619 Expect.isFalse(operator_negate.isConst, "Method is const"); |
| 620 Expect.isFalse(operator_negate.isFactory, "Method is factory"); | 620 Expect.isFalse(operator_negate.isFactory, "Method is factory"); |
| 621 Expect.isNull(operator_negate.constructorName, | 621 Expect.isNull(operator_negate.constructorName, |
| 622 "Method constructorName is non-null"); | 622 "Method constructorName is non-null"); |
| 623 Expect.isFalse(operator_negate.isGetter, "Method is getter"); | 623 Expect.isFalse(operator_negate.isGetter, "Method is getter"); |
| 624 Expect.isFalse(operator_negate.isSetter, "Method is setter"); | 624 Expect.isFalse(operator_negate.isSetter, "Method is setter"); |
| 625 Expect.isTrue(operator_negate.isOperator, "Method is not operator"); | 625 Expect.isTrue(operator_negate.isOperator, "Method is not operator"); |
| 626 Expect.stringEquals('negate', operator_negate.operatorName, | 626 Expect.stringEquals('negate', operator_negate.operatorName, |
| 627 "Unexpected operatorName"); | 627 "Unexpected operatorName"); |
| 628 | 628 |
| 629 | 629 |
| 630 var bazClassConstructors = bazClass.constructors(); | 630 var bazClassConstructors = bazClass.constructors; |
| 631 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); | 631 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); |
| 632 Expect.equals(3, bazClassConstructors.length, | 632 Expect.equals(3, bazClassConstructors.length, |
| 633 "Unexpected number of constructors"); | 633 "Unexpected number of constructors"); |
| 634 // TODO(johnniwinther): Add tests of constructors. | 634 // TODO(johnniwinther): Add tests of constructors. |
| 635 } | 635 } |
| OLD | NEW |