| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
| 7 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; | 7 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mirror
s.dart'; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart'; | 8 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart'; |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart'; | 9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/analyze.dart'
; |
| 10 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart' | 10 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart' |
| 11 show currentDirectory; | 11 show currentDirectory; |
| 12 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; | 12 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; |
| 13 | 13 |
| 14 import 'dart:io'; | 14 import 'dart:io'; |
| 15 | 15 |
| 16 final Uri DART_MIRRORS_URI = new Uri(scheme: 'dart', path: 'mirrors'); | 16 final Uri DART_MIRRORS_URI = new Uri(scheme: 'dart', path: 'mirrors'); |
| 17 | 17 |
| 18 int count(Iterable iterable) { | 18 int count(Iterable iterable) { |
| 19 var count = 0; | 19 var count = 0; |
| 20 for (var element in iterable) { | 20 for (var element in iterable) { |
| 21 count++; | 21 count++; |
| 22 } | 22 } |
| 23 return count; | 23 return count; |
| 24 } | 24 } |
| 25 | 25 |
| 26 bool containsType(TypeMirror expected, Iterable<TypeMirror> iterable) { | 26 bool containsType(TypeMirror expected, Iterable<TypeMirror> iterable) { |
| 27 for (var element in iterable) { | 27 for (var element in iterable) { |
| 28 if (element.originalDeclaration == expected.originalDeclaration) { | 28 if (element.originalDeclaration == expected.originalDeclaration) { |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 | 34 |
| 35 DeclarationMirror findMirror(Iterable<DeclarationMirror> list, String name) { | 35 DeclarationMirror findMirror(Iterable<DeclarationMirror> list, Symbol name) { |
| 36 for (DeclarationMirror mirror in list) { | 36 for (DeclarationMirror mirror in list) { |
| 37 if (mirror.simpleName == name) { | 37 if (mirror.simpleName == name) { |
| 38 return mirror; | 38 return mirror; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 return null; | 41 return null; |
| 42 } | 42 } |
| 43 | 43 |
| 44 main() { | 44 main() { |
| 45 Uri scriptUri = currentDirectory.resolveUri(Platform.script); | 45 Uri scriptUri = currentDirectory.resolveUri(Platform.script); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 }).then(asyncSuccess); | 57 }).then(asyncSuccess); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void test(MirrorSystem mirrors) { | 60 void test(MirrorSystem mirrors) { |
| 61 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); | 61 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); |
| 62 | 62 |
| 63 var libraries = mirrors.libraries; | 63 var libraries = mirrors.libraries; |
| 64 Expect.isNotNull(libraries, "No libraries map returned"); | 64 Expect.isNotNull(libraries, "No libraries map returned"); |
| 65 Expect.isFalse(libraries.isEmpty, "Empty libraries map returned"); | 65 Expect.isFalse(libraries.isEmpty, "Empty libraries map returned"); |
| 66 | 66 |
| 67 var helperLibrary = findMirror(libraries.values, "mirrors_helper"); | 67 var helperLibrary = findMirror(libraries.values, #mirrors_helper); |
| 68 Expect.isNotNull(helperLibrary, "Library 'mirrors_helper' not found"); | 68 Expect.isNotNull(helperLibrary, "Library 'mirrors_helper' not found"); |
| 69 Expect.stringEquals("mirrors_helper", helperLibrary.simpleName, | 69 Expect.equals(#mirrors_helper, helperLibrary.simpleName, |
| 70 "Unexpected library simple name"); | 70 "Unexpected library simple name"); |
| 71 Expect.stringEquals("mirrors_helper", helperLibrary.qualifiedName, | 71 Expect.equals(#mirrors_helper, helperLibrary.qualifiedName, |
| 72 "Unexpected library qualified name"); | 72 "Unexpected library qualified name"); |
| 73 Expect.equals(helperLibrary, mirrors.findLibrary('mirrors_helper')); | 73 Expect.equals(helperLibrary, mirrors.findLibrary(#mirrors_helper)); |
| 74 | 74 |
| 75 var helperLibraryLocation = helperLibrary.location; | 75 var helperLibraryLocation = helperLibrary.location; |
| 76 Expect.isNotNull(helperLibraryLocation); | 76 Expect.isNotNull(helperLibraryLocation); |
| 77 Expect.equals(271, helperLibraryLocation.offset, "Unexpected offset"); | 77 Expect.equals(271, helperLibraryLocation.offset, "Unexpected offset"); |
| 78 Expect.equals(23, helperLibraryLocation.length, "Unexpected length"); | 78 Expect.equals(23, helperLibraryLocation.length, "Unexpected length"); |
| 79 Expect.equals(9, helperLibraryLocation.line, "Unexpected line"); | 79 Expect.equals(9, helperLibraryLocation.line, "Unexpected line"); |
| 80 Expect.equals(1, helperLibraryLocation.column, "Unexpected column"); | 80 Expect.equals(1, helperLibraryLocation.column, "Unexpected column"); |
| 81 | 81 |
| 82 | 82 |
| 83 var classes = helperLibrary.classes; | 83 var declarations = helperLibrary.declarations; |
| 84 Expect.isNotNull(classes, "No classes map returned"); | 84 Expect.isNotNull(declarations, "No declarations map returned"); |
| 85 Expect.isFalse(classes.isEmpty, "Empty classes map returned"); | 85 Expect.isFalse(declarations.isEmpty, "Empty declarations map returned"); |
| 86 | 86 |
| 87 testFoo(mirrors, helperLibrary, classes); | 87 testFoo(mirrors, helperLibrary, declarations); |
| 88 testBar(mirrors, helperLibrary, classes); | 88 testBar(mirrors, helperLibrary, declarations); |
| 89 testBaz(mirrors, helperLibrary, classes); | 89 testBaz(mirrors, helperLibrary, declarations); |
| 90 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. | 90 // TODO(johnniwinther): Add test of class [Boz] and typedef [Func]. |
| 91 // TODO(johnniwinther): Add tests of type argument substitution, which | 91 // TODO(johnniwinther): Add tests of type argument substitution, which |
| 92 // is not currently implemented in dart2js. | 92 // is not currently implemented in dart2js. |
| 93 // TODO(johnniwinther): Add tests of Location and Source. | 93 // TODO(johnniwinther): Add tests of Location and Source. |
| 94 testPrivate(mirrors, helperLibrary, classes); | 94 testPrivate(mirrors, helperLibrary, declarations); |
| 95 // TODO(johnniwinther): Add thorough tests of [LibraryMirror.functions], | |
| 96 // [LibraryMirror.getters], [LibraryMirror.setters], [LibraryMirror.members], | |
| 97 // and [LibraryMirror.variable]. | |
| 98 Expect.isNotNull(helperLibrary.functions); | |
| 99 Expect.isNotNull(helperLibrary.members); | |
| 100 Expect.isNotNull(helperLibrary.getters); | |
| 101 Expect.isNotNull(helperLibrary.setters); | |
| 102 Expect.isNotNull(helperLibrary.variables); | |
| 103 } | 95 } |
| 104 | 96 |
| 105 // Testing class Foo: | 97 // Testing class Foo: |
| 106 // | 98 // |
| 107 // class Foo { | 99 // class Foo { |
| 108 // | 100 // |
| 109 // } | 101 // } |
| 110 void testFoo(MirrorSystem system, LibraryMirror helperLibrary, | 102 void testFoo(MirrorSystem system, LibraryMirror helperLibrary, |
| 111 Map<String,TypeMirror> classes) { | 103 Map<Symbol, DeclarationMirror> declarations) { |
| 112 var fooClass = classes["Foo"]; | 104 var fooClass = declarations[#Foo]; |
| 113 Expect.isNotNull(fooClass, "Type 'Foo' not found"); | 105 Expect.isNotNull(fooClass, "Type 'Foo' not found"); |
| 114 Expect.isTrue(fooClass is ClassMirror, | 106 Expect.isTrue(fooClass is ClassMirror, |
| 115 "Unexpected mirror type returned"); | 107 "Unexpected mirror type returned"); |
| 116 Expect.stringEquals("Foo", fooClass.simpleName, | 108 Expect.equals(#Foo, fooClass.simpleName, |
| 117 "Unexpected type simple name"); | 109 "Unexpected type simple name"); |
| 118 Expect.stringEquals("mirrors_helper.Foo", fooClass.qualifiedName, | 110 Expect.equals(#mirrors_helper.Foo, fooClass.qualifiedName, |
| 119 "Unexpected type qualified name"); | 111 "Unexpected type qualified name"); |
| 120 | 112 |
| 121 Expect.equals(helperLibrary, fooClass.library, | 113 Expect.equals(helperLibrary, getLibrary(fooClass), |
| 122 "Unexpected library returned from type"); | 114 "Unexpected library returned from type"); |
| 123 | 115 |
| 124 Expect.isFalse(fooClass.isObject, "Class is Object"); | 116 Expect.isFalse(isObject(fooClass), "Class is Object"); |
| 125 Expect.isFalse(fooClass.isDynamic, "Class is dynamic"); | 117 Expect.isFalse(fooClass.isDynamic, "Class is dynamic"); |
| 126 Expect.isFalse(fooClass.isVoid, "Class is void"); | 118 Expect.isFalse(fooClass.isVoid, "Class is void"); |
| 127 Expect.isFalse(fooClass.isTypeVariable, "Class is a type variable"); | 119 Expect.isFalse(fooClass is TypeVariableMirror, "Class is a type variable"); |
| 128 Expect.isFalse(fooClass.isTypedef, "Class is a typedef"); | 120 Expect.isFalse(fooClass is TypedefMirror, "Class is a typedef"); |
| 129 Expect.isFalse(fooClass.isFunction, "Class is a function"); | 121 Expect.isFalse(fooClass is FunctionTypeMirror, "Class is a function"); |
| 130 | 122 |
| 131 Expect.isTrue(fooClass.isOriginalDeclaration); | 123 Expect.isTrue(fooClass.isOriginalDeclaration); |
| 132 Expect.equals(fooClass, fooClass.originalDeclaration); | 124 Expect.equals(fooClass, fooClass.originalDeclaration); |
| 133 | 125 |
| 134 Expect.isTrue(fooClass.isClass, "Class is not class"); | 126 Expect.isTrue(fooClass is ClassMirror, "Class is not class"); |
| 135 Expect.isFalse(fooClass.isAbstract); | 127 Expect.isFalse(fooClass.isAbstract); |
| 136 Expect.isFalse(fooClass.isPrivate, "Class is private"); | 128 Expect.isFalse(fooClass.isPrivate, "Class is private"); |
| 137 | 129 |
| 138 var objectType = fooClass.superclass; | 130 var objectType = fooClass.superclass; |
| 139 Expect.isNotNull(objectType, "Superclass is null"); | 131 Expect.isNotNull(objectType, "Superclass is null"); |
| 140 Expect.isTrue(objectType.isObject, "Object is not Object"); | 132 Expect.isTrue(isObject(objectType), "Object is not Object"); |
| 141 Expect.isFalse(objectType.isOriginalDeclaration); | 133 Expect.isTrue(objectType.isOriginalDeclaration); |
| 142 Expect.isTrue(containsType(fooClass, | 134 Expect.isTrue(containsType(fooClass, |
| 143 computeSubdeclarations(objectType)), | 135 computeSubdeclarations(system, objectType)), |
| 144 "Class is not subclass of superclass"); | 136 "Class is not subclass of superclass"); |
| 145 | 137 |
| 146 var fooInterfaces = fooClass.superinterfaces; | 138 var fooInterfaces = fooClass.superinterfaces; |
| 147 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); | 139 Expect.isNotNull(fooInterfaces, "Interfaces map is null"); |
| 148 Expect.isTrue(fooInterfaces.isEmpty, "Interfaces map is not empty"); | 140 Expect.isTrue(fooInterfaces.isEmpty, "Interfaces map is not empty"); |
| 149 | 141 |
| 150 var fooSubdeclarations = computeSubdeclarations(fooClass); | 142 var fooSubdeclarations = computeSubdeclarations(system, fooClass); |
| 151 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); | 143 Expect.equals(1, count(fooSubdeclarations), "Unexpected subtype count"); |
| 152 for (var fooSubdeclaration in fooSubdeclarations) { | 144 for (var fooSubdeclaration in fooSubdeclarations) { |
| 153 Expect.equals(fooClass, fooSubdeclaration.superclass.originalDeclaration); | 145 Expect.equals(fooClass, fooSubdeclaration.superclass.originalDeclaration); |
| 154 } | 146 } |
| 155 | 147 |
| 156 Expect.throws(() => fooClass.typeArguments, | 148 Expect.isTrue(fooClass.typeArguments.isEmpty); |
| 157 (exception) => true, | |
| 158 "Class has type arguments"); | |
| 159 var fooClassTypeVariables = fooClass.typeVariables; | 149 var fooClassTypeVariables = fooClass.typeVariables; |
| 160 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); | 150 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); |
| 161 Expect.isTrue(fooClassTypeVariables.isEmpty, | 151 Expect.isTrue(fooClassTypeVariables.isEmpty, |
| 162 "Type variable list is not empty"); | 152 "Type variable list is not empty"); |
| 163 | 153 |
| 164 var fooClassMembers = fooClass.members; | 154 var fooClassMembers = fooClass.declarations; |
| 165 Expect.isNotNull(fooClassMembers, "Declared members map is null"); | 155 Expect.isNotNull(fooClassMembers, "Declared members map is null"); |
| 166 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); | 156 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); |
| 167 | 157 |
| 168 var fooClassConstructors = fooClass.constructors; | |
| 169 Expect.isNotNull(fooClassConstructors, "Constructors map is null"); | |
| 170 Expect.isTrue(fooClassConstructors.isEmpty, | |
| 171 "Constructors map is unempty"); | |
| 172 | |
| 173 // TODO(johnniwinther): Add thorough tests of [ClassMirror.functions], | |
| 174 // [ClassMirror.getters], [ClassMirror.setters], [ClassMirror.members], | |
| 175 // and [ClassMirror.variable]. | |
| 176 Expect.isNotNull(fooClass.functions); | |
| 177 Expect.isNotNull(fooClass.members); | |
| 178 Expect.isNotNull(fooClass.getters); | |
| 179 Expect.isNotNull(fooClass.setters); | |
| 180 Expect.isNotNull(fooClass.variables); | |
| 181 | |
| 182 ////////////////////////////////////////////////////////////////////////////// | 158 ////////////////////////////////////////////////////////////////////////////// |
| 183 // Metadata tests | 159 // Metadata tests |
| 184 ////////////////////////////////////////////////////////////////////////////// | 160 ////////////////////////////////////////////////////////////////////////////// |
| 185 | 161 |
| 186 var metadataList = fooClass.metadata; | 162 var metadataList = fooClass.metadata; |
| 187 Expect.isNotNull(metadataList); | 163 Expect.isNotNull(metadataList); |
| 188 Expect.equals(16, metadataList.length); | 164 Expect.equals(16, metadataList.length); |
| 189 var metadataListIndex = 0; | 165 var metadataListIndex = 0; |
| 190 var metadata; | 166 var metadata; |
| 191 | 167 |
| 192 var dartMirrorsLibrary = system.libraries[DART_MIRRORS_URI]; | 168 var dartMirrorsLibrary = system.libraries[DART_MIRRORS_URI]; |
| 193 Expect.isNotNull(dartMirrorsLibrary); | 169 Expect.isNotNull(dartMirrorsLibrary); |
| 194 var commentType = dartMirrorsLibrary.classes['Comment']; | 170 var commentType = dartMirrorsLibrary.declarations[#Comment]; |
| 195 Expect.isNotNull(commentType); | 171 Expect.isNotNull(commentType); |
| 196 | 172 |
| 197 // /// Singleline doc comment. | 173 // /// Singleline doc comment. |
| 198 metadata = metadataList[metadataListIndex++]; | 174 metadata = metadataList[metadataListIndex++]; |
| 199 Expect.isTrue(metadata is InstanceMirror); | 175 Expect.isTrue(metadata is InstanceMirror); |
| 200 Expect.isFalse(metadata.hasReflectee); | 176 Expect.isFalse(metadata.hasReflectee); |
| 201 Expect.throws(() => metadata.reflectee, (_) => true); | 177 Expect.throws(() => metadata.reflectee, (_) => true); |
| 202 Expect.isTrue(metadata is CommentInstanceMirror); | 178 Expect.isTrue(metadata is CommentInstanceMirror); |
| 203 Expect.equals(commentType.originalDeclaration, metadata.type); | 179 Expect.equals(commentType.originalDeclaration, metadata.type); |
| 204 Expect.isTrue(metadata.isDocComment); | 180 Expect.isTrue(metadata.isDocComment); |
| 205 Expect.stringEquals( | 181 Expect.stringEquals( |
| 206 "/// Singleline doc comment.", metadata.text); | 182 "/// Singleline doc comment.", metadata.text); |
| 207 Expect.stringEquals( | 183 Expect.stringEquals( |
| 208 "Singleline doc comment.", metadata.trimmedText); | 184 "Singleline doc comment.", metadata.trimmedText); |
| 209 | 185 |
| 210 // @Metadata | 186 // @Metadata |
| 211 metadata = metadataList[metadataListIndex++]; | 187 metadata = metadataList[metadataListIndex++]; |
| 212 Expect.isTrue(metadata is InstanceMirror); | 188 Expect.isTrue(metadata is InstanceMirror); |
| 213 Expect.isFalse(metadata.hasReflectee); | 189 Expect.isFalse(metadata.hasReflectee); |
| 214 Expect.throws(() => metadata.reflectee, (_) => true); | 190 Expect.throws(() => metadata.reflectee, (_) => true); |
| 215 Expect.isTrue(metadata is TypeInstanceMirror); | 191 Expect.isTrue(metadata is TypeInstanceMirror); |
| 216 var metadataType = metadata.representedType; | 192 var metadataType = metadata.representedType; |
| 217 Expect.isNotNull(metadataType); | 193 Expect.isNotNull(metadataType); |
| 218 Expect.stringEquals('Metadata', metadataType.simpleName); | 194 Expect.equals(#Metadata, metadataType.simpleName); |
| 219 | 195 |
| 220 // // This is intentionally the type literal. | 196 // // This is intentionally the type literal. |
| 221 metadata = metadataList[metadataListIndex++]; | 197 metadata = metadataList[metadataListIndex++]; |
| 222 Expect.isTrue(metadata is InstanceMirror); | 198 Expect.isTrue(metadata is InstanceMirror); |
| 223 Expect.isFalse(metadata.hasReflectee); | 199 Expect.isFalse(metadata.hasReflectee); |
| 224 Expect.throws(() => metadata.reflectee, (_) => true); | 200 Expect.throws(() => metadata.reflectee, (_) => true); |
| 225 Expect.isTrue(metadata is CommentInstanceMirror); | 201 Expect.isTrue(metadata is CommentInstanceMirror); |
| 226 Expect.equals(commentType.originalDeclaration, metadata.type); | 202 Expect.equals(commentType.originalDeclaration, metadata.type); |
| 227 Expect.isFalse(metadata.isDocComment); | 203 Expect.isFalse(metadata.isDocComment); |
| 228 Expect.stringEquals( | 204 Expect.stringEquals( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 255 "// Singleline comment 2.", metadata.text); | 231 "// Singleline comment 2.", metadata.text); |
| 256 Expect.stringEquals( | 232 Expect.stringEquals( |
| 257 "Singleline comment 2.", metadata.trimmedText); | 233 "Singleline comment 2.", metadata.trimmedText); |
| 258 | 234 |
| 259 // @Metadata(null) | 235 // @Metadata(null) |
| 260 metadata = metadataList[metadataListIndex++]; | 236 metadata = metadataList[metadataListIndex++]; |
| 261 Expect.isTrue(metadata is InstanceMirror); | 237 Expect.isTrue(metadata is InstanceMirror); |
| 262 Expect.isFalse(metadata.hasReflectee); | 238 Expect.isFalse(metadata.hasReflectee); |
| 263 Expect.throws(() => metadata.reflectee, (_) => true); | 239 Expect.throws(() => metadata.reflectee, (_) => true); |
| 264 Expect.equals(metadataType.originalDeclaration, metadata.type); | 240 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 265 InstanceMirror data = metadata.getField('data'); | 241 InstanceMirror data = metadata.getField(#data); |
| 266 Expect.isNotNull(data); | 242 Expect.isNotNull(data); |
| 267 Expect.isTrue(data.hasReflectee); | 243 Expect.isTrue(data.hasReflectee); |
| 268 Expect.isNull(data.reflectee); | 244 Expect.isNull(data.reflectee); |
| 269 | 245 |
| 270 // @Metadata(true) | 246 // @Metadata(true) |
| 271 metadata = metadataList[metadataListIndex++]; | 247 metadata = metadataList[metadataListIndex++]; |
| 272 Expect.isTrue(metadata is InstanceMirror); | 248 Expect.isTrue(metadata is InstanceMirror); |
| 273 Expect.isFalse(metadata.hasReflectee); | 249 Expect.isFalse(metadata.hasReflectee); |
| 274 Expect.throws(() => metadata.reflectee, (_) => true); | 250 Expect.throws(() => metadata.reflectee, (_) => true); |
| 275 Expect.equals(metadataType.originalDeclaration, metadata.type); | 251 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 276 data = metadata.getField('data'); | 252 data = metadata.getField(#data); |
| 277 Expect.isNotNull(data); | 253 Expect.isNotNull(data); |
| 278 Expect.isTrue(data.hasReflectee); | 254 Expect.isTrue(data.hasReflectee); |
| 279 Expect.isTrue(data.reflectee); | 255 Expect.isTrue(data.reflectee); |
| 280 | 256 |
| 281 // @Metadata(false) | 257 // @Metadata(false) |
| 282 metadata = metadataList[metadataListIndex++]; | 258 metadata = metadataList[metadataListIndex++]; |
| 283 Expect.isTrue(metadata is InstanceMirror); | 259 Expect.isTrue(metadata is InstanceMirror); |
| 284 Expect.isFalse(metadata.hasReflectee); | 260 Expect.isFalse(metadata.hasReflectee); |
| 285 Expect.throws(() => metadata.reflectee, (_) => true); | 261 Expect.throws(() => metadata.reflectee, (_) => true); |
| 286 Expect.equals(metadataType.originalDeclaration, metadata.type); | 262 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 287 data = metadata.getField('data'); | 263 data = metadata.getField(#data); |
| 288 Expect.isNotNull(data); | 264 Expect.isNotNull(data); |
| 289 Expect.isTrue(data.hasReflectee); | 265 Expect.isTrue(data.hasReflectee); |
| 290 Expect.isFalse(data.reflectee); | 266 Expect.isFalse(data.reflectee); |
| 291 | 267 |
| 292 // @Metadata(0) | 268 // @Metadata(0) |
| 293 metadata = metadataList[metadataListIndex++]; | 269 metadata = metadataList[metadataListIndex++]; |
| 294 Expect.isTrue(metadata is InstanceMirror); | 270 Expect.isTrue(metadata is InstanceMirror); |
| 295 Expect.isFalse(metadata.hasReflectee); | 271 Expect.isFalse(metadata.hasReflectee); |
| 296 Expect.throws(() => metadata.reflectee, (_) => true); | 272 Expect.throws(() => metadata.reflectee, (_) => true); |
| 297 Expect.equals(metadataType.originalDeclaration, metadata.type); | 273 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 298 data = metadata.getField('data'); | 274 data = metadata.getField(#data); |
| 299 Expect.isNotNull(data); | 275 Expect.isNotNull(data); |
| 300 Expect.isTrue(data.hasReflectee); | 276 Expect.isTrue(data.hasReflectee); |
| 301 Expect.equals(0, data.reflectee); | 277 Expect.equals(0, data.reflectee); |
| 302 | 278 |
| 303 // @Metadata(1.5) | 279 // @Metadata(1.5) |
| 304 metadata = metadataList[metadataListIndex++]; | 280 metadata = metadataList[metadataListIndex++]; |
| 305 Expect.isTrue(metadata is InstanceMirror); | 281 Expect.isTrue(metadata is InstanceMirror); |
| 306 Expect.isFalse(metadata.hasReflectee); | 282 Expect.isFalse(metadata.hasReflectee); |
| 307 Expect.throws(() => metadata.reflectee, (_) => true); | 283 Expect.throws(() => metadata.reflectee, (_) => true); |
| 308 Expect.equals(metadataType.originalDeclaration, metadata.type); | 284 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 309 data = metadata.getField('data'); | 285 data = metadata.getField(#data); |
| 310 Expect.isNotNull(data); | 286 Expect.isNotNull(data); |
| 311 Expect.isTrue(data.hasReflectee); | 287 Expect.isTrue(data.hasReflectee); |
| 312 Expect.equals(1.5, data.reflectee); | 288 Expect.equals(1.5, data.reflectee); |
| 313 | 289 |
| 314 // @Metadata("Foo") | 290 // @Metadata("Foo") |
| 315 metadata = metadataList[metadataListIndex++]; | 291 metadata = metadataList[metadataListIndex++]; |
| 316 Expect.isTrue(metadata is InstanceMirror); | 292 Expect.isTrue(metadata is InstanceMirror); |
| 317 Expect.isFalse(metadata.hasReflectee); | 293 Expect.isFalse(metadata.hasReflectee); |
| 318 Expect.throws(() => metadata.reflectee, (_) => true); | 294 Expect.throws(() => metadata.reflectee, (_) => true); |
| 319 Expect.equals(metadataType.originalDeclaration, metadata.type); | 295 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 320 data = metadata.getField('data'); | 296 data = metadata.getField(#data); |
| 321 Expect.isNotNull(data); | 297 Expect.isNotNull(data); |
| 322 Expect.isTrue(data.hasReflectee); | 298 Expect.isTrue(data.hasReflectee); |
| 323 Expect.stringEquals("Foo", data.reflectee); | 299 Expect.stringEquals("Foo", data.reflectee); |
| 324 | 300 |
| 325 // @Metadata(const ["Foo"]) | 301 // @Metadata(const ["Foo"]) |
| 326 metadata = metadataList[metadataListIndex++]; | 302 metadata = metadataList[metadataListIndex++]; |
| 327 Expect.isTrue(metadata is InstanceMirror); | 303 Expect.isTrue(metadata is InstanceMirror); |
| 328 Expect.isFalse(metadata.hasReflectee); | 304 Expect.isFalse(metadata.hasReflectee); |
| 329 Expect.throws(() => metadata.reflectee, (_) => true); | 305 Expect.throws(() => metadata.reflectee, (_) => true); |
| 330 Expect.equals(metadataType.originalDeclaration, metadata.type); | 306 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 331 data = metadata.getField('data'); | 307 data = metadata.getField(#data); |
| 332 Expect.isTrue(data is ListInstanceMirror); | 308 Expect.isTrue(data is ListInstanceMirror); |
| 333 Expect.isFalse(data.hasReflectee); | 309 Expect.isFalse(data.hasReflectee); |
| 334 Expect.throws(() => data.reflectee, (_) => true); | 310 Expect.throws(() => data.reflectee, (_) => true); |
| 335 ListInstanceMirror listData = data; | 311 ListInstanceMirror listData = data; |
| 336 Expect.equals(1, listData.length); | 312 Expect.equals(1, listData.length); |
| 337 InstanceMirror element = listData[0]; | 313 InstanceMirror element = listData.getElement(0); |
| 338 Expect.isNotNull(element); | 314 Expect.isNotNull(element); |
| 339 Expect.isTrue(element.hasReflectee); | 315 Expect.isTrue(element.hasReflectee); |
| 340 Expect.stringEquals("Foo", element.reflectee); | 316 Expect.stringEquals("Foo", element.reflectee); |
| 341 | 317 |
| 342 // @Metadata(/* Inline comment */ const {'foo':"Foo"}) | 318 // @Metadata(/* Inline comment */ const {'foo':"Foo"}) |
| 343 metadata = metadataList[metadataListIndex++]; | 319 metadata = metadataList[metadataListIndex++]; |
| 344 Expect.isTrue(metadata is InstanceMirror); | 320 Expect.isTrue(metadata is InstanceMirror); |
| 345 Expect.isFalse(metadata.hasReflectee); | 321 Expect.isFalse(metadata.hasReflectee); |
| 346 Expect.throws(() => metadata.reflectee, (_) => true); | 322 Expect.throws(() => metadata.reflectee, (_) => true); |
| 347 Expect.equals(metadataType.originalDeclaration, metadata.type); | 323 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 348 data = metadata.getField('data'); | 324 data = metadata.getField(#data); |
| 349 Expect.isTrue(data is MapInstanceMirror); | 325 Expect.isTrue(data is MapInstanceMirror); |
| 350 Expect.isFalse(data.hasReflectee); | 326 Expect.isFalse(data.hasReflectee); |
| 351 Expect.throws(() => data.reflectee, (_) => true); | 327 Expect.throws(() => data.reflectee, (_) => true); |
| 352 MapInstanceMirror mapData = data; | 328 MapInstanceMirror mapData = data; |
| 353 Expect.equals(1, mapData.length); | 329 Expect.equals(1, mapData.length); |
| 354 var it = mapData.keys.iterator; | 330 var it = mapData.keys.iterator; |
| 355 Expect.isTrue(it.moveNext()); | 331 Expect.isTrue(it.moveNext()); |
| 356 Expect.stringEquals('foo', it.current); | 332 Expect.stringEquals('foo', it.current); |
| 357 element = mapData['foo']; | 333 element = mapData.getValue('foo'); |
| 358 Expect.isNotNull(element); | 334 Expect.isNotNull(element); |
| 359 Expect.isTrue(element.hasReflectee); | 335 Expect.isTrue(element.hasReflectee); |
| 360 Expect.stringEquals("Foo", element.reflectee); | 336 Expect.stringEquals("Foo", element.reflectee); |
| 361 Expect.isNull(mapData['bar']); | 337 Expect.isNull(mapData.getValue('bar')); |
| 362 | 338 |
| 363 // @metadata | 339 // @metadata |
| 364 metadata = metadataList[metadataListIndex++]; | 340 metadata = metadataList[metadataListIndex++]; |
| 365 Expect.isTrue(metadata is InstanceMirror); | 341 Expect.isTrue(metadata is InstanceMirror); |
| 366 Expect.isFalse(metadata.hasReflectee); | 342 Expect.isFalse(metadata.hasReflectee); |
| 367 Expect.throws(() => metadata.reflectee, (_) => true); | 343 Expect.throws(() => metadata.reflectee, (_) => true); |
| 368 Expect.equals(metadataType.originalDeclaration, metadata.type); | 344 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 369 data = metadata.getField('data'); | 345 data = metadata.getField(#data); |
| 370 Expect.isNotNull(data); | 346 Expect.isNotNull(data); |
| 371 Expect.isTrue(data.hasReflectee); | 347 Expect.isTrue(data.hasReflectee); |
| 372 Expect.isNull(data.reflectee); | 348 Expect.isNull(data.reflectee); |
| 373 | 349 |
| 374 // /** Multiline doc comment. */ | 350 // /** Multiline doc comment. */ |
| 375 metadata = metadataList[metadataListIndex++]; | 351 metadata = metadataList[metadataListIndex++]; |
| 376 Expect.isTrue(metadata is InstanceMirror); | 352 Expect.isTrue(metadata is InstanceMirror); |
| 377 Expect.isFalse(metadata.hasReflectee); | 353 Expect.isFalse(metadata.hasReflectee); |
| 378 Expect.throws(() => metadata.reflectee, (_) => true); | 354 Expect.throws(() => metadata.reflectee, (_) => true); |
| 379 Expect.isTrue(metadata is CommentInstanceMirror); | 355 Expect.isTrue(metadata is CommentInstanceMirror); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 Expect.equals(1, fooClassLocation.column, "Unexpected column"); | 390 Expect.equals(1, fooClassLocation.column, "Unexpected column"); |
| 415 | 391 |
| 416 } | 392 } |
| 417 | 393 |
| 418 // Testing abstract class Bar: | 394 // Testing abstract class Bar: |
| 419 // | 395 // |
| 420 // abstract class Bar<E> { | 396 // abstract class Bar<E> { |
| 421 // | 397 // |
| 422 // } | 398 // } |
| 423 void testBar(MirrorSystem system, LibraryMirror helperLibrary, | 399 void testBar(MirrorSystem system, LibraryMirror helperLibrary, |
| 424 Map<String,TypeMirror> classes) { | 400 Map<Symbol, DeclarationMirror> classes) { |
| 425 var barClass = classes["Bar"]; | 401 var barClass = classes[#Bar]; |
| 426 Expect.isNotNull(barClass, "Type 'Bar' not found"); | 402 Expect.isNotNull(barClass, "Type 'Bar' not found"); |
| 427 Expect.isTrue(barClass is ClassMirror, | 403 Expect.isTrue(barClass is ClassMirror, |
| 428 "Unexpected mirror type returned"); | 404 "Unexpected mirror type returned"); |
| 429 Expect.stringEquals("Bar", barClass.simpleName, | 405 Expect.equals(#Bar, barClass.simpleName, |
| 430 "Unexpected type simple name"); | 406 "Unexpected type simple name"); |
| 431 Expect.stringEquals("mirrors_helper.Bar", barClass.qualifiedName, | 407 Expect.equals(#mirrors_helper.Bar, barClass.qualifiedName, |
| 432 "Unexpected type qualified name"); | 408 "Unexpected type qualified name"); |
| 433 | 409 |
| 434 Expect.equals(helperLibrary, barClass.library, | 410 Expect.equals(helperLibrary, getLibrary(barClass), |
| 435 "Unexpected library returned from type"); | 411 "Unexpected library returned from type"); |
| 436 | 412 |
| 437 Expect.isFalse(barClass.isObject, "Interface is Object"); | 413 Expect.isFalse(isObject(barClass), "Interface is Object"); |
| 438 Expect.isFalse(barClass.isDynamic, "Interface is dynamic"); | 414 Expect.isFalse(barClass.isDynamic, "Interface is dynamic"); |
| 439 Expect.isFalse(barClass.isVoid, "Interface is void"); | 415 Expect.isFalse(barClass.isVoid, "Interface is void"); |
| 440 Expect.isFalse(barClass.isTypeVariable, "Interface is a type variable"); | 416 Expect.isFalse(barClass is TypeVariableMirror, "Interface is a type variable")
; |
| 441 Expect.isFalse(barClass.isTypedef, "Interface is a typedef"); | 417 Expect.isFalse(barClass is TypedefMirror, "Interface is a typedef"); |
| 442 Expect.isFalse(barClass.isFunction, "Interface is a function"); | 418 Expect.isFalse(barClass is FunctionTypeMirror, "Interface is a function"); |
| 443 | 419 |
| 444 Expect.isTrue(barClass.isOriginalDeclaration); | 420 Expect.isTrue(barClass.isOriginalDeclaration); |
| 445 Expect.equals(barClass, barClass.originalDeclaration); | 421 Expect.equals(barClass, barClass.originalDeclaration); |
| 446 | 422 |
| 447 Expect.isTrue(barClass.isClass); | 423 Expect.isTrue(barClass is ClassMirror); |
| 448 Expect.isTrue(barClass.isAbstract); | 424 Expect.isTrue(barClass.isAbstract); |
| 449 Expect.isFalse(barClass.isPrivate, "Interface is private"); | 425 Expect.isFalse(barClass.isPrivate, "Interface is private"); |
| 450 | 426 |
| 451 var objectType = barClass.superclass; | 427 var objectType = barClass.superclass; |
| 452 Expect.isNotNull(objectType, "Superclass is null"); | 428 Expect.isNotNull(objectType, "Superclass is null"); |
| 453 Expect.isTrue(objectType.isObject, "Object is not Object"); | 429 Expect.isTrue(isObject(objectType), "Object is not Object"); |
| 454 Expect.isFalse(objectType.isOriginalDeclaration); | 430 Expect.isTrue(objectType.isOriginalDeclaration); |
| 455 Expect.isTrue(containsType(barClass, | 431 Expect.isTrue(containsType(barClass, |
| 456 computeSubdeclarations(objectType)), | 432 computeSubdeclarations(system, objectType)), |
| 457 "Class is not subclass of superclass"); | 433 "Class is not subclass of superclass"); |
| 458 | 434 |
| 459 var barInterfaces = barClass.superinterfaces; | 435 var barInterfaces = barClass.superinterfaces; |
| 460 Expect.isNotNull(barInterfaces, "Interfaces map is null"); | 436 Expect.isNotNull(barInterfaces, "Interfaces map is null"); |
| 461 Expect.isTrue(barInterfaces.isEmpty, "Interfaces map is not empty"); | 437 Expect.isTrue(barInterfaces.isEmpty, "Interfaces map is not empty"); |
| 462 | 438 |
| 463 var barSubdeclarations = computeSubdeclarations(barClass); | 439 var barSubdeclarations = computeSubdeclarations(system, barClass); |
| 464 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); | 440 Expect.equals(1, count(barSubdeclarations), "Unexpected subtype count"); |
| 465 for (var barSubdeclaration in barSubdeclarations) { | 441 for (var barSubdeclaration in barSubdeclarations) { |
| 466 Expect.isTrue(containsType(barClass, | 442 Expect.isTrue(containsType(barClass, |
| 467 barSubdeclaration.superinterfaces), | 443 barSubdeclaration.superinterfaces), |
| 468 "Interface is not superinterface of subclass"); | 444 "Interface is not superinterface of subclass"); |
| 469 } | 445 } |
| 470 | 446 |
| 471 Expect.throws(() => barClass.typeArguments, | 447 Expect.isTrue(barClass.typeArguments.isEmpty); |
| 472 (exception) => true, | |
| 473 "Interface has type arguments"); | |
| 474 var barInterfaceTypeVariables = barClass.typeVariables; | 448 var barInterfaceTypeVariables = barClass.typeVariables; |
| 475 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null"); | 449 Expect.isNotNull(barInterfaceTypeVariables, "Type variable list is null"); |
| 476 Expect.isFalse(barInterfaceTypeVariables.isEmpty, | 450 Expect.isFalse(barInterfaceTypeVariables.isEmpty, |
| 477 "Type variable list is empty"); | 451 "Type variable list is empty"); |
| 478 Expect.equals(barInterfaceTypeVariables.length, 1, | 452 Expect.equals(barInterfaceTypeVariables.length, 1, |
| 479 "Unexpected number of type variables"); | 453 "Unexpected number of type variables"); |
| 480 | 454 |
| 481 var barE = barInterfaceTypeVariables[0]; | 455 var barE = barInterfaceTypeVariables[0]; |
| 482 Expect.isNotNull(barE, "Type variable is null"); | 456 Expect.isNotNull(barE, "Type variable is null"); |
| 483 Expect.isTrue(barE.isTypeVariable, "Type variable is not type variable"); | 457 Expect.isTrue(barE is TypeVariableMirror); |
| 484 | 458 |
| 485 var barInterfaceMembers = barClass.members; | 459 var barInterfaceMembers = barClass.declarations; |
| 486 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); | 460 Expect.isNotNull(barInterfaceMembers, "Declared members map is null"); |
| 487 Expect.isTrue(barInterfaceMembers.isEmpty, | 461 Expect.isTrue(barInterfaceMembers.isEmpty, |
| 488 "Declared members map is unempty"); | 462 "Declarations map is unempty"); |
| 489 | |
| 490 var barInterfaceConstructors = barClass.constructors; | |
| 491 Expect.isNotNull(barInterfaceConstructors, "Constructors map is null"); | |
| 492 Expect.isTrue(barInterfaceConstructors.isEmpty, | |
| 493 "Constructors map is unempty"); | |
| 494 | 463 |
| 495 var metadata = barClass.metadata; | 464 var metadata = barClass.metadata; |
| 496 Expect.isNotNull(metadata); | 465 Expect.isNotNull(metadata); |
| 497 Expect.equals(0, metadata.length); | 466 Expect.equals(0, metadata.length); |
| 498 } | 467 } |
| 499 | 468 |
| 500 // Testing class Baz: | 469 // Testing class Baz: |
| 501 // | 470 // |
| 502 // class Baz<E,F extends Foo> implements Bar<E> { | 471 // class Baz<E,F extends Foo> implements Bar<E> { |
| 503 // Baz(); | 472 // Baz(); |
| 504 // const Baz.named(); | 473 // const Baz.named(); |
| 505 // factory Baz.factory() => new Baz<E,F>(); | 474 // factory Baz.factory() => new Baz<E,F>(); |
| 506 // | 475 // |
| 507 // static method1(e) {} | 476 // static method1(e) {} |
| 508 // void method2(E e, [F f = null]) {} | 477 // void method2(E e, [F f = null]) {} |
| 509 // Baz<E,F> method3(E func1(F f), Func<E,F> func2) => null; | 478 // Baz<E,F> method3(E func1(F f), Func<E,F> func2) => null; |
| 510 // | 479 // |
| 511 // bool operator==(Object other) => false; | 480 // bool operator==(Object other) => false; |
| 512 // int operator -() => 0; | 481 // int operator -() => 0; |
| 513 // } | 482 // } |
| 514 void testBaz(MirrorSystem system, LibraryMirror helperLibrary, | 483 void testBaz(MirrorSystem system, LibraryMirror helperLibrary, |
| 515 Map<String,TypeMirror> classes) { | 484 Map<Symbol, DeclarationMirror> declarations) { |
| 516 var bazClass = classes["Baz"]; | 485 var bazClass = declarations[#Baz]; |
| 517 Expect.isNotNull(bazClass, "Type 'Baz' not found"); | 486 Expect.isNotNull(bazClass, "Type 'Baz' not found"); |
| 518 Expect.isTrue(bazClass is ClassMirror, | 487 Expect.isTrue(bazClass is ClassMirror, |
| 519 "Unexpected mirror type returned"); | 488 "Unexpected mirror type returned"); |
| 520 Expect.stringEquals("Baz", bazClass.simpleName, | 489 Expect.equals(#Baz, bazClass.simpleName, |
| 521 "Unexpected type simple name"); | 490 "Unexpected type simple name"); |
| 522 Expect.stringEquals("mirrors_helper.Baz", bazClass.qualifiedName, | 491 Expect.equals(#mirrors_helper.Baz, bazClass.qualifiedName, |
| 523 "Unexpected type qualified name"); | 492 "Unexpected type qualified name"); |
| 524 | 493 |
| 525 Expect.equals(helperLibrary, bazClass.library, | 494 Expect.equals(helperLibrary, getLibrary(bazClass), |
| 526 "Unexpected library returned from type"); | 495 "Unexpected library returned from type"); |
| 527 | 496 |
| 528 Expect.isFalse(bazClass.isObject, "Class is Object"); | 497 Expect.isFalse(isObject(bazClass), "Class is Object"); |
| 529 Expect.isFalse(bazClass.isDynamic, "Class is dynamic"); | 498 Expect.isFalse(bazClass.isDynamic, "Class is dynamic"); |
| 530 Expect.isFalse(bazClass.isVoid, "Class is void"); | 499 Expect.isFalse(bazClass.isVoid, "Class is void"); |
| 531 Expect.isFalse(bazClass.isTypeVariable, "Class is a type variable"); | 500 Expect.isFalse(bazClass is TypeVariableMirror, "Class is a type variable"); |
| 532 Expect.isFalse(bazClass.isTypedef, "Class is a typedef"); | 501 Expect.isFalse(bazClass is TypedefMirror, "Class is a typedef"); |
| 533 Expect.isFalse(bazClass.isFunction, "Class is a function"); | 502 Expect.isFalse(bazClass is FunctionTypeMirror, "Class is a function"); |
| 534 | 503 |
| 535 Expect.isTrue(bazClass.isOriginalDeclaration); | 504 Expect.isTrue(bazClass.isOriginalDeclaration); |
| 536 Expect.equals(bazClass, bazClass.originalDeclaration); | 505 Expect.equals(bazClass, bazClass.originalDeclaration); |
| 537 | 506 |
| 538 Expect.isTrue(bazClass.isClass, "Class is not class"); | 507 Expect.isTrue(bazClass is ClassMirror, "Class is not class"); |
| 539 Expect.isFalse(bazClass.isAbstract); | 508 Expect.isFalse(bazClass.isAbstract); |
| 540 Expect.isFalse(bazClass.isPrivate, "Class is private"); | 509 Expect.isFalse(bazClass.isPrivate, "Class is private"); |
| 541 | 510 |
| 542 var objectType = bazClass.superclass; | 511 var objectType = bazClass.superclass; |
| 543 Expect.isNotNull(objectType, "Superclass is null"); | 512 Expect.isNotNull(objectType, "Superclass is null"); |
| 544 Expect.isTrue(objectType.isObject, "Object is not Object"); | 513 Expect.isTrue(isObject(objectType), "Object is not Object"); |
| 545 Expect.isFalse(objectType.isOriginalDeclaration); | 514 Expect.isTrue(objectType.isOriginalDeclaration); |
| 546 Expect.isTrue(containsType(bazClass, | 515 Expect.isTrue(containsType(bazClass, |
| 547 computeSubdeclarations(objectType)), | 516 computeSubdeclarations(system, objectType)), |
| 548 "Class is not subclass of superclass"); | 517 "Class is not subclass of superclass"); |
| 549 | 518 |
| 550 var bazInterfaces = bazClass.superinterfaces; | 519 var bazInterfaces = bazClass.superinterfaces; |
| 551 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); | 520 Expect.isNotNull(bazInterfaces, "Interfaces map is null"); |
| 552 Expect.isTrue(!bazInterfaces.isEmpty, "Interfaces map is empty"); | 521 Expect.isTrue(!bazInterfaces.isEmpty, "Interfaces map is empty"); |
| 553 for (var bazInterface in bazInterfaces) { | 522 for (var bazInterface in bazInterfaces) { |
| 554 Expect.isTrue(containsType(bazClass, | 523 Expect.isTrue(containsType(bazClass, |
| 555 computeSubdeclarations(objectType)), | 524 computeSubdeclarations(system, objectType)), |
| 556 "Class is not subclass of superinterface"); | 525 "Class is not subclass of superinterface"); |
| 557 } | 526 } |
| 558 | 527 |
| 559 var bazSubdeclarations = computeSubdeclarations(bazClass); | 528 var bazSubdeclarations = computeSubdeclarations(system, bazClass); |
| 560 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); | 529 Expect.equals(0, count(bazSubdeclarations), "Unexpected subtype count"); |
| 561 | 530 |
| 562 var barInterface = findMirror(bazInterfaces, "Bar"); | 531 var barInterface = findMirror(bazInterfaces, #Bar); |
| 563 Expect.isNotNull(barInterface, "Interface bar is missing"); | 532 Expect.isNotNull(barInterface, "Interface bar is missing"); |
| 564 Expect.isFalse(barInterface.isOriginalDeclaration); | 533 Expect.isFalse(barInterface.isOriginalDeclaration); |
| 565 var barInterfaceTypeArguments = barInterface.typeArguments; | 534 var barInterfaceTypeArguments = barInterface.typeArguments; |
| 566 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); | 535 Expect.isNotNull(barInterfaceTypeArguments, "Type arguments are missing"); |
| 567 Expect.equals(1, barInterfaceTypeArguments.length, | 536 Expect.equals(1, barInterfaceTypeArguments.length, |
| 568 "Type arguments is empty"); | 537 "Type arguments is empty"); |
| 569 | 538 |
| 570 Expect.throws(() => bazClass.typeArguments, | 539 Expect.isTrue(bazClass.typeArguments.isEmpty, "Class has type arguments"); |
| 571 (exception) => true, | |
| 572 "Class has type arguments"); | |
| 573 var bazClassTypeVariables = bazClass.typeVariables; | 540 var bazClassTypeVariables = bazClass.typeVariables; |
| 574 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null"); | 541 Expect.isNotNull(bazClassTypeVariables, "Type variable list is null"); |
| 575 Expect.equals(2, bazClassTypeVariables.length, | 542 Expect.equals(2, bazClassTypeVariables.length, |
| 576 "Type variable list is not empty"); | 543 "Type variable list is not empty"); |
| 577 | 544 |
| 578 var bazE = bazClassTypeVariables[0]; | 545 var bazE = bazClassTypeVariables[0]; |
| 579 Expect.isNotNull(bazE, "Type variable is null"); | 546 Expect.isNotNull(bazE, "Type variable is null"); |
| 580 Expect.stringEquals('E', bazE.simpleName, "Unexpected simpleName"); | 547 Expect.equals(#E, bazE.simpleName, "Unexpected simpleName"); |
| 581 Expect.stringEquals('mirrors_helper.Baz.E', bazE.qualifiedName, | 548 Expect.equals(#mirrors_helper.Baz.E, bazE.qualifiedName, |
| 582 "Unexpected qualifiedName"); | 549 "Unexpected qualifiedName"); |
| 583 Expect.equals(bazClass, bazE.declarer, | 550 Expect.equals(bazClass, bazE.owner, |
| 584 "Unexpected type variable declarer"); | 551 "Unexpected type variable declarer"); |
| 585 var bazEbound = bazE.upperBound; | 552 var bazEbound = bazE.upperBound; |
| 586 Expect.isNotNull(bazEbound); | 553 Expect.isNotNull(bazEbound); |
| 587 Expect.isFalse(bazEbound.isOriginalDeclaration); | 554 Expect.isTrue(bazEbound.isOriginalDeclaration); |
| 588 Expect.isTrue(bazEbound.isObject, "Bound is not object"); | 555 Expect.isTrue(isObject(bazEbound), "Bound is not object"); |
| 589 | 556 |
| 590 var bazF = bazClassTypeVariables[1]; | 557 var bazF = bazClassTypeVariables[1]; |
| 591 Expect.isNotNull(bazF, "Type variable is null"); | 558 Expect.isNotNull(bazF, "Type variable is null"); |
| 592 Expect.stringEquals('F', bazF.simpleName, "Unexpected simpleName"); | 559 Expect.equals(#F, bazF.simpleName, "Unexpected simpleName"); |
| 593 Expect.stringEquals('mirrors_helper.Baz.F', bazF.qualifiedName, | 560 Expect.equals(#mirrors_helper.Baz.F, bazF.qualifiedName, |
| 594 "Unexpected qualifiedName"); | 561 "Unexpected qualifiedName"); |
| 595 Expect.equals(bazClass, bazF.declarer); | 562 Expect.equals(bazClass, bazF.owner); |
| 596 var bazFbound = bazF.upperBound; | 563 var bazFbound = bazF.upperBound; |
| 597 Expect.isNotNull(bazFbound); | 564 Expect.isNotNull(bazFbound); |
| 598 Expect.isFalse(bazFbound.isOriginalDeclaration); | 565 Expect.isTrue(bazFbound.isOriginalDeclaration); |
| 599 Expect.stringEquals("mirrors_helper.Foo", bazFbound.qualifiedName, | 566 Expect.equals(#mirrors_helper.Foo, bazFbound.qualifiedName, |
| 600 "Bound is not Foo"); | 567 "Bound is not Foo"); |
| 601 | 568 |
| 602 var bazClassMembers = bazClass.members; | 569 var bazClassMembers = bazClass.declarations; |
| 603 Expect.isNotNull(bazClassMembers, "Declared members map is null"); | 570 Expect.isNotNull(bazClassMembers, "Declared members map is null"); |
| 604 Expect.equals(8, bazClassMembers.length, | 571 Expect.equals(8, bazClassMembers.length, |
| 605 "Unexpected number of declared members"); | 572 "Unexpected number of declared members"); |
| 606 | 573 |
| 607 //////////////////////////////////////////////////////////////////////////// | 574 //////////////////////////////////////////////////////////////////////////// |
| 608 // static method1(e) {} | 575 // static method1(e) {} |
| 609 //////////////////////////////////////////////////////////////////////////// | 576 //////////////////////////////////////////////////////////////////////////// |
| 610 var method1 = bazClassMembers["method1"]; | 577 var method1 = bazClassMembers[#method1]; |
| 611 Expect.isNotNull(method1, "method1 not found"); | 578 Expect.isNotNull(method1, "method1 not found"); |
| 612 Expect.stringEquals('method1', method1.simpleName, | 579 Expect.equals(#method1, method1.simpleName); |
| 613 "Unexpected method simpleName"); | 580 Expect.equals(#mirrors_helper.Baz.method1, method1.qualifiedName); |
| 614 Expect.stringEquals('mirrors_helper.Baz.method1', method1.qualifiedName, | |
| 615 "Unexpected method qualifiedName"); | |
| 616 Expect.equals(method1.owner, bazClass); | 581 Expect.equals(method1.owner, bazClass); |
| 617 Expect.isFalse(method1.isTopLevel); | 582 Expect.isFalse(method1.isTopLevel); |
| 583 Expect.isTrue(method1 is MethodMirror); |
| 618 Expect.isFalse(method1.isConstructor); | 584 Expect.isFalse(method1.isConstructor); |
| 619 Expect.isFalse(method1.isVariable); | |
| 620 Expect.isTrue(method1.isMethod); | |
| 621 Expect.isFalse(method1.isPrivate); | 585 Expect.isFalse(method1.isPrivate); |
| 622 Expect.isTrue(method1.isStatic); | 586 Expect.isTrue(method1.isStatic); |
| 623 Expect.isTrue(method1 is MethodMirror); | |
| 624 Expect.isTrue(method1.isRegularMethod); | 587 Expect.isTrue(method1.isRegularMethod); |
| 625 Expect.isFalse(method1.isConstConstructor); | 588 Expect.isFalse(method1.isConstConstructor); |
| 626 Expect.isFalse(method1.isGenerativeConstructor); | 589 Expect.isFalse(method1.isGenerativeConstructor); |
| 627 Expect.isFalse(method1.isRedirectingConstructor); | 590 Expect.isFalse(method1.isRedirectingConstructor); |
| 628 Expect.isFalse(method1.isFactoryConstructor); | 591 Expect.isFalse(method1.isFactoryConstructor); |
| 629 Expect.isFalse(method1.isGetter); | 592 Expect.isFalse(method1.isGetter); |
| 630 Expect.isFalse(method1.isSetter); | 593 Expect.isFalse(method1.isSetter); |
| 631 Expect.isFalse(method1.isOperator); | 594 Expect.isFalse(method1.isOperator); |
| 632 | 595 |
| 633 var dynamicType = method1.returnType; | 596 var dynamicType = method1.returnType; |
| 634 Expect.isNotNull(dynamicType, "Return type was null"); | 597 Expect.isNotNull(dynamicType, "Return type was null"); |
| 635 Expect.isFalse(dynamicType.isObject, "dynamic is Object"); | 598 Expect.isFalse(isObject(dynamicType), "dynamic is Object"); |
| 636 Expect.isTrue(dynamicType.isDynamic, "dynamic is not dynamic"); | 599 Expect.isTrue(dynamicType.isDynamic, "dynamic is not dynamic"); |
| 637 Expect.isFalse(dynamicType.isVoid, "dynamic is void"); | 600 Expect.isFalse(dynamicType.isVoid, "dynamic is void"); |
| 638 Expect.isFalse(dynamicType.isTypeVariable, "dynamic is a type variable"); | 601 Expect.isFalse(dynamicType is TypeVariableMirror, "dynamic is a type variable"
); |
| 639 Expect.isFalse(dynamicType.isTypedef, "dynamic is a typedef"); | 602 Expect.isFalse(dynamicType is TypedefMirror, "dynamic is a typedef"); |
| 640 Expect.isFalse(dynamicType.isFunction, "dynamic is a function"); | 603 Expect.isFalse(dynamicType is FunctionTypeMirror, "dynamic is a function"); |
| 641 | 604 |
| 642 var method1Parameters = method1.parameters; | 605 var method1Parameters = method1.parameters; |
| 643 Expect.isNotNull(method1Parameters, "Method parameters is null"); | 606 Expect.isNotNull(method1Parameters, "Method parameters is null"); |
| 644 Expect.equals(1, method1Parameters.length, "Unexpected parameter count"); | 607 Expect.equals(1, method1Parameters.length, "Unexpected parameter count"); |
| 645 var method1Parameter1 = method1Parameters[0]; | 608 var method1Parameter1 = method1Parameters[0]; |
| 646 Expect.isNotNull(method1Parameter1, "Parameter is null"); | 609 Expect.isNotNull(method1Parameter1, "Parameter is null"); |
| 647 Expect.equals(dynamicType, method1Parameter1.type); | 610 Expect.equals(dynamicType, method1Parameter1.type); |
| 648 Expect.stringEquals("e", method1Parameter1.simpleName, | 611 Expect.equals(#e, method1Parameter1.simpleName); |
| 649 "Unexpected parameter simpleName"); | 612 Expect.equals(#mirrors_helper.Baz.method1.e, method1Parameter1.qualifiedName); |
| 650 Expect.stringEquals("mirrors_helper.Baz.method1#e", | |
| 651 method1Parameter1.qualifiedName, | |
| 652 "Unexpected parameter qualifiedName"); | |
| 653 Expect.isFalse(method1Parameter1.hasDefaultValue, | 613 Expect.isFalse(method1Parameter1.hasDefaultValue, |
| 654 "Parameter has default value"); | 614 "Parameter has default value"); |
| 655 Expect.isNull(method1Parameter1.defaultValue, | 615 Expect.isNull(method1Parameter1.defaultValue, |
| 656 "Parameter default value is non-null"); | 616 "Parameter default value is non-null"); |
| 657 Expect.isFalse(method1Parameter1.isOptional, "Parameter is optional"); | 617 Expect.isFalse(method1Parameter1.isOptional, "Parameter is optional"); |
| 658 | 618 |
| 659 //////////////////////////////////////////////////////////////////////////// | 619 //////////////////////////////////////////////////////////////////////////// |
| 660 // static void method2(E e, [F f = null]) {} | 620 // static void method2(E e, [F f = null]) {} |
| 661 //////////////////////////////////////////////////////////////////////////// | 621 //////////////////////////////////////////////////////////////////////////// |
| 662 var method2 = bazClassMembers["method2"]; | 622 var method2 = bazClassMembers[#method2]; |
| 663 Expect.isNotNull(method2, "method2 not found"); | 623 Expect.isNotNull(method2, "method2 not found"); |
| 664 Expect.stringEquals('method2', method2.simpleName, | 624 Expect.equals(#method2, method2.simpleName); |
| 665 "Unexpected method simpleName"); | 625 Expect.equals(#mirrors_helper.Baz.method2, method2.qualifiedName); |
| 666 Expect.stringEquals('mirrors_helper.Baz.method2', method2.qualifiedName, | |
| 667 "Unexpected method qualifiedName"); | |
| 668 Expect.equals(method2.owner, bazClass); | 626 Expect.equals(method2.owner, bazClass); |
| 669 Expect.isFalse(method2.isTopLevel); | 627 Expect.isFalse(method2.isTopLevel); |
| 628 Expect.isTrue(method2 is MethodMirror); |
| 670 Expect.isFalse(method2.isConstructor); | 629 Expect.isFalse(method2.isConstructor); |
| 671 Expect.isFalse(method2.isVariable); | |
| 672 Expect.isTrue(method2.isMethod); | |
| 673 Expect.isFalse(method2.isPrivate); | 630 Expect.isFalse(method2.isPrivate); |
| 674 Expect.isFalse(method2.isStatic); | 631 Expect.isFalse(method2.isStatic); |
| 675 Expect.isTrue(method2 is MethodMirror); | |
| 676 Expect.isTrue(method2.isRegularMethod); | 632 Expect.isTrue(method2.isRegularMethod); |
| 677 Expect.isFalse(method2.isConstConstructor); | 633 Expect.isFalse(method2.isConstConstructor); |
| 678 Expect.isFalse(method2.isGenerativeConstructor); | 634 Expect.isFalse(method2.isGenerativeConstructor); |
| 679 Expect.isFalse(method2.isRedirectingConstructor); | 635 Expect.isFalse(method2.isRedirectingConstructor); |
| 680 Expect.isFalse(method2.isFactoryConstructor); | 636 Expect.isFalse(method2.isFactoryConstructor); |
| 681 Expect.isFalse(method2.isGetter); | 637 Expect.isFalse(method2.isGetter); |
| 682 Expect.isFalse(method2.isSetter); | 638 Expect.isFalse(method2.isSetter); |
| 683 Expect.isFalse(method2.isOperator); | 639 Expect.isFalse(method2.isOperator); |
| 684 | 640 |
| 685 var voidType = method2.returnType; | 641 var voidType = method2.returnType; |
| 686 Expect.isNotNull(voidType, "Return type was null"); | 642 Expect.isNotNull(voidType, "Return type was null"); |
| 687 Expect.isFalse(voidType.isObject, "void is Object"); | 643 Expect.isFalse(isObject(voidType), "void is Object"); |
| 688 Expect.isFalse(voidType.isDynamic, "void is dynamic"); | 644 Expect.isFalse(voidType.isDynamic, "void is dynamic"); |
| 689 Expect.isTrue(voidType.isVoid, "void is not void"); | 645 Expect.isTrue(voidType.isVoid, "void is not void"); |
| 690 Expect.isFalse(voidType.isTypeVariable, "void is a type variable"); | 646 Expect.isFalse(voidType is TypeVariableMirror, "void is a type variable"); |
| 691 Expect.isFalse(voidType.isTypedef, "void is a typedef"); | 647 Expect.isFalse(voidType is TypedefMirror, "void is a typedef"); |
| 692 Expect.isFalse(voidType.isFunction, "void is a function"); | 648 Expect.isFalse(voidType is FunctionTypeMirror, "void is a function"); |
| 693 | 649 |
| 694 var method2Parameters = method2.parameters; | 650 var method2Parameters = method2.parameters; |
| 695 Expect.isNotNull(method2Parameters, "Method parameters is null"); | 651 Expect.isNotNull(method2Parameters, "Method parameters is null"); |
| 696 Expect.equals(2, method2Parameters.length, "Unexpected parameter count"); | 652 Expect.equals(2, method2Parameters.length, "Unexpected parameter count"); |
| 697 var method2Parameter1 = method2Parameters[0]; | 653 var method2Parameter1 = method2Parameters[0]; |
| 698 Expect.isNotNull(method2Parameter1, "Parameter is null"); | 654 Expect.isNotNull(method2Parameter1, "Parameter is null"); |
| 699 Expect.equals(bazE, method2Parameter1.type); | 655 Expect.equals(bazE, method2Parameter1.type); |
| 700 Expect.stringEquals("e", method2Parameter1.simpleName, | 656 Expect.equals(#e, method2Parameter1.simpleName); |
| 701 "Unexpected parameter simpleName"); | 657 Expect.equals(#mirrors_helper.Baz.method2.e, method2Parameter1.qualifiedName); |
| 702 Expect.stringEquals("mirrors_helper.Baz.method2#e", | |
| 703 method2Parameter1.qualifiedName, | |
| 704 "Unexpected parameter qualifiedName"); | |
| 705 Expect.isFalse(method2Parameter1.hasDefaultValue, | 658 Expect.isFalse(method2Parameter1.hasDefaultValue, |
| 706 "Parameter has default value"); | 659 "Parameter has default value"); |
| 707 Expect.isNull(method2Parameter1.defaultValue, | 660 Expect.isNull(method2Parameter1.defaultValue, |
| 708 "Parameter default value is non-null"); | 661 "Parameter default value is non-null"); |
| 709 Expect.isFalse(method2Parameter1.isOptional, "Parameter is optional"); | 662 Expect.isFalse(method2Parameter1.isOptional, "Parameter is optional"); |
| 710 var method2Parameter2 = method2Parameters[1]; | 663 var method2Parameter2 = method2Parameters[1]; |
| 711 Expect.isNotNull(method2Parameter2, "Parameter is null"); | 664 Expect.isNotNull(method2Parameter2, "Parameter is null"); |
| 712 Expect.equals(bazF, method2Parameter2.type); | 665 Expect.equals(bazF, method2Parameter2.type); |
| 713 Expect.stringEquals("f", method2Parameter2.simpleName, | 666 Expect.equals(#f, method2Parameter2.simpleName); |
| 714 "Unexpected parameter simpleName"); | 667 Expect.equals(#mirrors_helper.Baz.method2.f, |
| 715 Expect.stringEquals("mirrors_helper.Baz.method2#f", | 668 method2Parameter2.qualifiedName); |
| 716 method2Parameter2.qualifiedName, | |
| 717 "Unexpected parameter qualifiedName"); | |
| 718 Expect.isTrue(method2Parameter2.hasDefaultValue, | 669 Expect.isTrue(method2Parameter2.hasDefaultValue, |
| 719 "Parameter has default value"); | 670 "Parameter has default value"); |
| 720 Expect.stringEquals("null", method2Parameter2.defaultValue, | 671 Expect.isNotNull(method2Parameter2.defaultValue, |
| 721 "Parameter default value is non-null"); | 672 "Parameter default value is null"); |
| 722 Expect.isTrue(method2Parameter2.isOptional, "Parameter is not optional"); | 673 Expect.isTrue(method2Parameter2.isOptional, "Parameter is not optional"); |
| 723 | 674 |
| 724 //////////////////////////////////////////////////////////////////////////// | 675 //////////////////////////////////////////////////////////////////////////// |
| 725 // Baz<E,F> method3(E func1(F f), Func<E,F> func2) => null; | 676 // Baz<E,F> method3(E func1(F f), Func<E,F> func2) => null; |
| 726 //////////////////////////////////////////////////////////////////////////// | 677 //////////////////////////////////////////////////////////////////////////// |
| 727 var method3 = bazClassMembers["method3"]; | 678 var method3 = bazClassMembers[#method3]; |
| 728 Expect.isNotNull(method3, "method3 not found"); | 679 Expect.isNotNull(method3, "method3 not found"); |
| 729 Expect.stringEquals('method3', method3.simpleName, | 680 Expect.equals(#method3, method3.simpleName); |
| 730 "Unexpected method simpleName"); | 681 Expect.equals(#mirrors_helper.Baz.method3, method3.qualifiedName); |
| 731 Expect.stringEquals('mirrors_helper.Baz.method3', method3.qualifiedName, | |
| 732 "Unexpected method qualifiedName"); | |
| 733 Expect.equals(method3.owner, bazClass); | 682 Expect.equals(method3.owner, bazClass); |
| 734 Expect.isFalse(method3.isTopLevel); | 683 Expect.isFalse(method3.isTopLevel); |
| 684 Expect.isTrue(method3 is MethodMirror); |
| 735 Expect.isFalse(method3.isConstructor); | 685 Expect.isFalse(method3.isConstructor); |
| 736 Expect.isFalse(method3.isVariable); | |
| 737 Expect.isTrue(method3.isMethod); | |
| 738 Expect.isFalse(method3.isPrivate); | 686 Expect.isFalse(method3.isPrivate); |
| 739 Expect.isFalse(method3.isStatic); | 687 Expect.isFalse(method3.isStatic); |
| 740 Expect.isTrue(method3 is MethodMirror); | |
| 741 Expect.isTrue(method3.isRegularMethod); | 688 Expect.isTrue(method3.isRegularMethod); |
| 742 Expect.isFalse(method3.isConstConstructor); | 689 Expect.isFalse(method3.isConstConstructor); |
| 743 Expect.isFalse(method3.isGenerativeConstructor); | 690 Expect.isFalse(method3.isGenerativeConstructor); |
| 744 Expect.isFalse(method3.isRedirectingConstructor); | 691 Expect.isFalse(method3.isRedirectingConstructor); |
| 745 Expect.isFalse(method3.isFactoryConstructor); | 692 Expect.isFalse(method3.isFactoryConstructor); |
| 746 Expect.isFalse(method3.isGetter); | 693 Expect.isFalse(method3.isGetter); |
| 747 Expect.isFalse(method3.isSetter); | 694 Expect.isFalse(method3.isSetter); |
| 748 Expect.isFalse(method3.isOperator); | 695 Expect.isFalse(method3.isOperator); |
| 749 | 696 |
| 750 var method3ReturnType = method3.returnType; | 697 var method3ReturnType = method3.returnType; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 766 Expect.equals(bazE, method3Parameter1type.returnType, | 713 Expect.equals(bazE, method3Parameter1type.returnType, |
| 767 "Return type of 'func1' is not a E"); | 714 "Return type of 'func1' is not a E"); |
| 768 Expect.isNotNull(method3Parameter1type.parameters, | 715 Expect.isNotNull(method3Parameter1type.parameters, |
| 769 "Parameters of 'func1' is null"); | 716 "Parameters of 'func1' is null"); |
| 770 Expect.equals(1, method3Parameter1type.parameters.length, | 717 Expect.equals(1, method3Parameter1type.parameters.length, |
| 771 "Unexpected parameter count of 'func1'"); | 718 "Unexpected parameter count of 'func1'"); |
| 772 Expect.equals(bazE, method3Parameter1type.returnType, | 719 Expect.equals(bazE, method3Parameter1type.returnType, |
| 773 "Return type of 'func1' is not a E"); | 720 "Return type of 'func1' is not a E"); |
| 774 Expect.isNotNull(method3Parameter1type.parameters[0], | 721 Expect.isNotNull(method3Parameter1type.parameters[0], |
| 775 "Parameter 1 of 'func1' is null"); | 722 "Parameter 1 of 'func1' is null"); |
| 776 Expect.stringEquals('f', method3Parameter1type.parameters[0].simpleName, | 723 Expect.equals(#f, method3Parameter1type.parameters[0].simpleName); |
| 777 "Unexpected name parameter 1 of 'func1'"); | |
| 778 Expect.equals(bazF, method3Parameter1type.parameters[0].type, | 724 Expect.equals(bazF, method3Parameter1type.parameters[0].type, |
| 779 "Argument type of 'func1' is not a F"); | 725 "Argument type of 'func1' is not a F"); |
| 780 Expect.stringEquals("func1", method3Parameter1.simpleName, | 726 Expect.equals(#func1, method3Parameter1.simpleName); |
| 781 "Unexpected parameter simpleName"); | 727 Expect.equals(#mirrors_helper.Baz.method3.func1, |
| 782 Expect.stringEquals("mirrors_helper.Baz.method3#func1", | 728 method3Parameter1.qualifiedName); |
| 783 method3Parameter1.qualifiedName, | |
| 784 "Unexpected parameter qualifiedName"); | |
| 785 Expect.isFalse(method3Parameter1.hasDefaultValue, | 729 Expect.isFalse(method3Parameter1.hasDefaultValue, |
| 786 "Parameter has default value"); | 730 "Parameter has default value"); |
| 787 Expect.isNull(method3Parameter1.defaultValue, | 731 Expect.isNull(method3Parameter1.defaultValue, |
| 788 "Parameter default value is non-null"); | 732 "Parameter default value is non-null"); |
| 789 Expect.isFalse(method3Parameter1.isOptional, "Parameter is optional"); | 733 Expect.isFalse(method3Parameter1.isOptional, "Parameter is optional"); |
| 790 | 734 |
| 791 var method3Parameter2 = method3Parameters[1]; | 735 var method3Parameter2 = method3Parameters[1]; |
| 792 Expect.isNotNull(method3Parameter2, "Parameter is null"); | 736 Expect.isNotNull(method3Parameter2, "Parameter is null"); |
| 793 var funcTypedef = method3Parameter2.type; | 737 var funcTypedef = method3Parameter2.type; |
| 794 Expect.isNotNull(funcTypedef, "Parameter type is null"); | 738 Expect.isNotNull(funcTypedef, "Parameter type is null"); |
| 795 Expect.stringEquals("Func", funcTypedef.simpleName, | 739 Expect.equals(#Func, funcTypedef.simpleName); |
| 796 "Unexpected simpleName"); | 740 Expect.equals(#mirrors_helper.Func, funcTypedef.qualifiedName); |
| 797 Expect.stringEquals("mirrors_helper.Func", funcTypedef.qualifiedName, | 741 Expect.isFalse(isObject(funcTypedef), "Typedef is Object"); |
| 798 "Unexpected simpleName"); | |
| 799 Expect.isFalse(funcTypedef.isObject, "Typedef is Object"); | |
| 800 Expect.isFalse(funcTypedef.isDynamic, "Typedef is dynamic"); | 742 Expect.isFalse(funcTypedef.isDynamic, "Typedef is dynamic"); |
| 801 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); | 743 Expect.isFalse(funcTypedef.isVoid, "Typedef is void"); |
| 802 Expect.isFalse(funcTypedef.isTypeVariable, "Typedef is a type variable"); | 744 Expect.isFalse(funcTypedef is TypeVariableMirror, "Typedef is a type variable"
); |
| 803 Expect.isTrue(funcTypedef.isTypedef, "Typedef is not a typedef"); | 745 Expect.isTrue(funcTypedef is TypedefMirror, "Typedef is not a typedef"); |
| 804 Expect.isFalse(funcTypedef.isFunction, "Typedef is a function"); | 746 Expect.isFalse(funcTypedef is FunctionTypeMirror, "Typedef is a function"); |
| 805 | 747 |
| 806 Expect.equals(helperLibrary, funcTypedef.library, | 748 Expect.equals(helperLibrary, getLibrary(funcTypedef), |
| 807 "Unexpected typedef library"); | 749 "Unexpected typedef library"); |
| 808 Expect.isNull(funcTypedef.superclass, "Non-null superclass on typedef"); | |
| 809 Expect.isNotNull(funcTypedef.superinterfaces); | |
| 810 Expect.isTrue(funcTypedef.superinterfaces.isEmpty); | |
| 811 Expect.isNotNull(funcTypedef.members); | |
| 812 Expect.isTrue(funcTypedef.members.isEmpty); | |
| 813 | 750 |
| 814 // TODO(johnniwinther): Returned typedef should not be the original | 751 Expect.isFalse(funcTypedef.isOriginalDeclaration); |
| 815 // declaration: | 752 Expect.isFalse(funcTypedef is ClassMirror, "Typedef is class"); |
| 816 Expect.isTrue(funcTypedef.isOriginalDeclaration); | |
| 817 Expect.isFalse(funcTypedef.isClass, "Typedef is class"); | |
| 818 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); | 753 Expect.isFalse(funcTypedef.isPrivate, "Typedef is private"); |
| 819 // TODO(johnniwinther): Should not throw an exception since the type should | 754 Expect.equals(2, funcTypedef.typeArguments.length); |
| 820 // not be the original declaration. | |
| 821 Expect.throws(() => funcTypedef.typeArguments, | |
| 822 (exception) => true, | |
| 823 "Typedef has type arguments"); | |
| 824 var funcTypedefTypeVariables = funcTypedef.typeVariables; | 755 var funcTypedefTypeVariables = funcTypedef.typeVariables; |
| 825 Expect.isNotNull(funcTypedefTypeVariables); | 756 Expect.isNotNull(funcTypedefTypeVariables); |
| 826 Expect.equals(2, funcTypedefTypeVariables.length); | 757 Expect.equals(2, funcTypedefTypeVariables.length); |
| 827 | 758 |
| 828 var funcTypedefDefinition = funcTypedef.value; | 759 var funcTypedefDefinition = funcTypedef.referent; |
| 829 Expect.isNotNull(funcTypedefDefinition); | 760 Expect.isNotNull(funcTypedefDefinition); |
| 830 Expect.isTrue(funcTypedefDefinition is FunctionTypeMirror); | 761 Expect.isTrue(funcTypedefDefinition is FunctionTypeMirror); |
| 831 | 762 |
| 832 Expect.stringEquals("func2", method3Parameter2.simpleName, | 763 Expect.equals(#func2, method3Parameter2.simpleName); |
| 833 "Unexpected parameter simpleName"); | 764 Expect.equals(#mirrors_helper.Baz.method3.func2, |
| 834 Expect.stringEquals("mirrors_helper.Baz.method3#func2", | 765 method3Parameter2.qualifiedName); |
| 835 method3Parameter2.qualifiedName, | |
| 836 "Unexpected parameter qualifiedName"); | |
| 837 Expect.isFalse(method3Parameter2.hasDefaultValue, | 766 Expect.isFalse(method3Parameter2.hasDefaultValue, |
| 838 "Parameter 'func2' has default value: " | 767 "Parameter 'func2' has default value: " |
| 839 "${method3Parameter2.defaultValue}"); | 768 "${method3Parameter2.defaultValue}"); |
| 840 Expect.isNull(method3Parameter2.defaultValue, | 769 Expect.isNull(method3Parameter2.defaultValue, |
| 841 "Parameter default value is non-null"); | 770 "Parameter default value is non-null"); |
| 842 Expect.isFalse(method3Parameter2.isOptional, "Parameter is optional"); | 771 Expect.isFalse(method3Parameter2.isOptional, "Parameter is optional"); |
| 843 | 772 |
| 844 //////////////////////////////////////////////////////////////////////////// | 773 //////////////////////////////////////////////////////////////////////////// |
| 845 // bool operator==(Object other) => false; | 774 // bool operator==(Object other) => false; |
| 846 //////////////////////////////////////////////////////////////////////////// | 775 //////////////////////////////////////////////////////////////////////////// |
| 847 var operator_eq = bazClassMembers['==']; | 776 var operator_eq = bazClassMembers[const Symbol('==')]; |
| 848 Expect.isNotNull(operator_eq, "operator == not found"); | 777 Expect.isNotNull(operator_eq, "operator == not found"); |
| 849 Expect.stringEquals('==', operator_eq.simpleName, | 778 Expect.equals(const Symbol('=='), operator_eq.simpleName, |
| 850 "Unexpected method simpleName"); | 779 "Unexpected method simpleName"); |
| 851 Expect.stringEquals('operator ==', displayName(operator_eq)); | 780 Expect.stringEquals('operator ==', displayName(operator_eq)); |
| 852 Expect.stringEquals('mirrors_helper.Baz.==', | 781 Expect.equals(const Symbol('mirrors_helper.Baz.=='), |
| 853 operator_eq.qualifiedName, | 782 operator_eq.qualifiedName, |
| 854 "Unexpected method qualifiedName"); | 783 "Unexpected method qualifiedName"); |
| 855 Expect.equals(operator_eq.owner, bazClass); | 784 Expect.equals(operator_eq.owner, bazClass); |
| 856 Expect.isFalse(operator_eq.isTopLevel); | 785 Expect.isFalse(operator_eq.isTopLevel); |
| 786 Expect.isTrue(operator_eq is MethodMirror); |
| 857 Expect.isFalse(operator_eq.isConstructor); | 787 Expect.isFalse(operator_eq.isConstructor); |
| 858 Expect.isFalse(operator_eq.isVariable); | |
| 859 Expect.isTrue(operator_eq.isMethod); | |
| 860 Expect.isFalse(operator_eq.isPrivate); | 788 Expect.isFalse(operator_eq.isPrivate); |
| 861 Expect.isFalse(operator_eq.isStatic); | 789 Expect.isFalse(operator_eq.isStatic); |
| 862 Expect.isTrue(operator_eq is MethodMirror); | |
| 863 Expect.isTrue(operator_eq.isRegularMethod); | 790 Expect.isTrue(operator_eq.isRegularMethod); |
| 864 Expect.isFalse(operator_eq.isConstConstructor); | 791 Expect.isFalse(operator_eq.isConstConstructor); |
| 865 Expect.isFalse(operator_eq.isGenerativeConstructor); | 792 Expect.isFalse(operator_eq.isGenerativeConstructor); |
| 866 Expect.isFalse(operator_eq.isRedirectingConstructor); | 793 Expect.isFalse(operator_eq.isRedirectingConstructor); |
| 867 Expect.isFalse(operator_eq.isFactoryConstructor); | 794 Expect.isFalse(operator_eq.isFactoryConstructor); |
| 868 Expect.isFalse(operator_eq.isGetter); | 795 Expect.isFalse(operator_eq.isGetter); |
| 869 Expect.isFalse(operator_eq.isSetter); | 796 Expect.isFalse(operator_eq.isSetter); |
| 870 Expect.isTrue(operator_eq.isOperator); | 797 Expect.isTrue(operator_eq.isOperator); |
| 871 Expect.stringEquals('==', operatorName(operator_eq)); | 798 Expect.stringEquals('==', operatorName(operator_eq)); |
| 872 | 799 |
| 873 //////////////////////////////////////////////////////////////////////////// | 800 //////////////////////////////////////////////////////////////////////////// |
| 874 // int operator -() => 0; | 801 // int operator -() => 0; |
| 875 //////////////////////////////////////////////////////////////////////////// | 802 //////////////////////////////////////////////////////////////////////////// |
| 876 var operator_negate = bazClassMembers[Mirror.UNARY_MINUS]; | 803 var operator_negate = bazClassMembers[const Symbol('unary-')]; |
| 877 Expect.isNotNull(operator_negate, "operator < not found"); | 804 Expect.isNotNull(operator_negate, "operator < not found"); |
| 878 Expect.stringEquals(Mirror.UNARY_MINUS, operator_negate.simpleName, | 805 Expect.equals(const Symbol('unary-'), operator_negate.simpleName, |
| 879 "Unexpected method simpleName"); | 806 "Unexpected method simpleName"); |
| 880 Expect.stringEquals('operator -', displayName(operator_negate)); | 807 Expect.stringEquals('operator -', displayName(operator_negate)); |
| 881 Expect.stringEquals('mirrors_helper.Baz.${Mirror.UNARY_MINUS}', | 808 Expect.equals(const Symbol('mirrors_helper.Baz.unary-'), |
| 882 operator_negate.qualifiedName, | 809 operator_negate.qualifiedName, |
| 883 "Unexpected method qualifiedName"); | 810 "Unexpected method qualifiedName"); |
| 884 Expect.equals(operator_negate.owner, bazClass); | 811 Expect.equals(operator_negate.owner, bazClass); |
| 885 Expect.isFalse(operator_negate.isTopLevel); | 812 Expect.isFalse(operator_negate.isTopLevel); |
| 813 Expect.isTrue(operator_negate is MethodMirror); |
| 886 Expect.isFalse(operator_negate.isConstructor); | 814 Expect.isFalse(operator_negate.isConstructor); |
| 887 Expect.isFalse(operator_negate.isVariable); | |
| 888 Expect.isTrue(operator_negate.isMethod); | |
| 889 Expect.isFalse(operator_negate.isPrivate); | 815 Expect.isFalse(operator_negate.isPrivate); |
| 890 Expect.isFalse(operator_negate.isStatic); | 816 Expect.isFalse(operator_negate.isStatic); |
| 891 Expect.isTrue(operator_negate is MethodMirror); | |
| 892 Expect.isTrue(operator_negate.isRegularMethod); | 817 Expect.isTrue(operator_negate.isRegularMethod); |
| 893 Expect.isFalse(operator_negate.isConstConstructor); | 818 Expect.isFalse(operator_negate.isConstConstructor); |
| 894 Expect.isFalse(operator_negate.isGenerativeConstructor); | 819 Expect.isFalse(operator_negate.isGenerativeConstructor); |
| 895 Expect.isFalse(operator_negate.isRedirectingConstructor); | 820 Expect.isFalse(operator_negate.isRedirectingConstructor); |
| 896 Expect.isFalse(operator_negate.isFactoryConstructor); | 821 Expect.isFalse(operator_negate.isFactoryConstructor); |
| 897 Expect.isFalse(operator_negate.isGetter); | 822 Expect.isFalse(operator_negate.isGetter); |
| 898 Expect.isFalse(operator_negate.isSetter); | 823 Expect.isFalse(operator_negate.isSetter); |
| 899 Expect.isTrue(operator_negate.isOperator); | 824 Expect.isTrue(operator_negate.isOperator); |
| 900 Expect.stringEquals('-', operatorName(operator_negate)); | 825 Expect.stringEquals('-', operatorName(operator_negate)); |
| 901 | 826 |
| 902 | |
| 903 var bazClassConstructors = bazClass.constructors; | |
| 904 Expect.isNotNull(bazClassConstructors, "Constructors map is null"); | |
| 905 Expect.equals(3, bazClassConstructors.length, | |
| 906 "Unexpected number of constructors"); | |
| 907 | |
| 908 //////////////////////////////////////////////////////////////////////////// | 827 //////////////////////////////////////////////////////////////////////////// |
| 909 // Baz(); | 828 // Baz(); |
| 910 //////////////////////////////////////////////////////////////////////////// | 829 //////////////////////////////////////////////////////////////////////////// |
| 911 var bazClassNonameConstructor = bazClassConstructors['']; | 830 var bazClassNonameConstructor = bazClassMembers[const Symbol('')]; |
| 912 Expect.isNotNull(bazClassNonameConstructor); | 831 Expect.isNotNull(bazClassNonameConstructor); |
| 913 Expect.isTrue(bazClassNonameConstructor is MethodMirror); | 832 Expect.isTrue(bazClassNonameConstructor is MethodMirror); |
| 914 Expect.isTrue(bazClassNonameConstructor.isConstructor); | 833 Expect.isTrue(bazClassNonameConstructor.isConstructor); |
| 915 Expect.isFalse(bazClassNonameConstructor.isRegularMethod); | 834 Expect.isFalse(bazClassNonameConstructor.isRegularMethod); |
| 916 Expect.isFalse(bazClassNonameConstructor.isConstConstructor); | 835 Expect.isFalse(bazClassNonameConstructor.isConstConstructor); |
| 917 Expect.isTrue(bazClassNonameConstructor.isGenerativeConstructor); | 836 Expect.isTrue(bazClassNonameConstructor.isGenerativeConstructor); |
| 918 Expect.isFalse(bazClassNonameConstructor.isRedirectingConstructor); | 837 Expect.isFalse(bazClassNonameConstructor.isRedirectingConstructor); |
| 919 Expect.isFalse(bazClassNonameConstructor.isFactoryConstructor); | 838 Expect.isFalse(bazClassNonameConstructor.isFactoryConstructor); |
| 920 Expect.stringEquals('', bazClassNonameConstructor.simpleName); | 839 Expect.equals(const Symbol(''), bazClassNonameConstructor.simpleName); |
| 921 Expect.stringEquals('Baz', displayName(bazClassNonameConstructor)); | 840 Expect.stringEquals('Baz', displayName(bazClassNonameConstructor)); |
| 922 Expect.stringEquals('mirrors_helper.Baz.', | 841 Expect.equals(const Symbol('mirrors_helper.Baz.'), |
| 923 bazClassNonameConstructor.qualifiedName); | 842 bazClassNonameConstructor.qualifiedName); |
| 924 | 843 |
| 925 //////////////////////////////////////////////////////////////////////////// | 844 //////////////////////////////////////////////////////////////////////////// |
| 926 // const Baz.named(); | 845 // const Baz.named(); |
| 927 //////////////////////////////////////////////////////////////////////////// | 846 //////////////////////////////////////////////////////////////////////////// |
| 928 var bazClassNamedConstructor = bazClassConstructors['named']; | 847 var bazClassNamedConstructor = bazClassMembers[#named]; |
| 929 Expect.isNotNull(bazClassNamedConstructor); | 848 Expect.isNotNull(bazClassNamedConstructor); |
| 930 Expect.isTrue(bazClassNamedConstructor is MethodMirror); | 849 Expect.isTrue(bazClassNamedConstructor is MethodMirror); |
| 931 Expect.isTrue(bazClassNamedConstructor.isConstructor); | 850 Expect.isTrue(bazClassNamedConstructor.isConstructor); |
| 932 Expect.isFalse(bazClassNamedConstructor.isRegularMethod); | 851 Expect.isFalse(bazClassNamedConstructor.isRegularMethod); |
| 933 Expect.isTrue(bazClassNamedConstructor.isConstConstructor); | 852 Expect.isTrue(bazClassNamedConstructor.isConstConstructor); |
| 934 Expect.isFalse(bazClassNamedConstructor.isGenerativeConstructor); | 853 Expect.isFalse(bazClassNamedConstructor.isGenerativeConstructor); |
| 935 Expect.isFalse(bazClassNamedConstructor.isRedirectingConstructor); | 854 Expect.isFalse(bazClassNamedConstructor.isRedirectingConstructor); |
| 936 Expect.isFalse(bazClassNamedConstructor.isFactoryConstructor); | 855 Expect.isFalse(bazClassNamedConstructor.isFactoryConstructor); |
| 937 Expect.stringEquals('named', bazClassNamedConstructor.simpleName); | 856 Expect.equals(#named, bazClassNamedConstructor.simpleName); |
| 938 Expect.stringEquals('Baz.named', displayName(bazClassNamedConstructor)); | 857 Expect.stringEquals('Baz.named', displayName(bazClassNamedConstructor)); |
| 939 Expect.stringEquals('mirrors_helper.Baz.named', | 858 Expect.equals(#mirrors_helper.Baz.named, |
| 940 bazClassNamedConstructor.qualifiedName); | 859 bazClassNamedConstructor.qualifiedName); |
| 941 | 860 |
| 942 //////////////////////////////////////////////////////////////////////////// | 861 //////////////////////////////////////////////////////////////////////////// |
| 943 // factory Baz.factory() => new Baz<E,F>(); | 862 // factory Baz.factory() => new Baz<E,F>(); |
| 944 //////////////////////////////////////////////////////////////////////////// | 863 //////////////////////////////////////////////////////////////////////////// |
| 945 var bazClassFactoryConstructor = bazClassConstructors['factory']; | 864 var bazClassFactoryConstructor = bazClassMembers[#factory]; |
| 946 Expect.isNotNull(bazClassFactoryConstructor); | 865 Expect.isNotNull(bazClassFactoryConstructor); |
| 947 Expect.isTrue(bazClassFactoryConstructor is MethodMirror); | 866 Expect.isTrue(bazClassFactoryConstructor is MethodMirror); |
| 948 Expect.isTrue(bazClassFactoryConstructor.isConstructor); | 867 Expect.isTrue(bazClassFactoryConstructor.isConstructor); |
| 949 Expect.isFalse(bazClassFactoryConstructor.isRegularMethod); | 868 Expect.isFalse(bazClassFactoryConstructor.isRegularMethod); |
| 950 Expect.isFalse(bazClassFactoryConstructor.isConstConstructor); | 869 Expect.isFalse(bazClassFactoryConstructor.isConstConstructor); |
| 951 Expect.isFalse(bazClassFactoryConstructor.isGenerativeConstructor); | 870 Expect.isFalse(bazClassFactoryConstructor.isGenerativeConstructor); |
| 952 Expect.isFalse(bazClassFactoryConstructor.isRedirectingConstructor); | 871 Expect.isFalse(bazClassFactoryConstructor.isRedirectingConstructor); |
| 953 Expect.isTrue(bazClassFactoryConstructor.isFactoryConstructor); | 872 Expect.isTrue(bazClassFactoryConstructor.isFactoryConstructor); |
| 954 Expect.stringEquals('factory', bazClassFactoryConstructor.simpleName); | 873 Expect.equals(#factory, bazClassFactoryConstructor.simpleName); |
| 955 Expect.stringEquals('Baz.factory', displayName(bazClassFactoryConstructor)); | 874 Expect.stringEquals('Baz.factory', displayName(bazClassFactoryConstructor)); |
| 956 Expect.stringEquals('mirrors_helper.Baz.factory', | 875 Expect.equals(#mirrors_helper.Baz.factory, |
| 957 bazClassFactoryConstructor.qualifiedName); | 876 bazClassFactoryConstructor.qualifiedName); |
| 958 | 877 |
| 959 // TODO(johnniwinther): Add more tests of constructors. | 878 // TODO(johnniwinther): Add more tests of constructors. |
| 960 // TODO(johnniwinther): Add a test for unnamed factory methods. | 879 // TODO(johnniwinther): Add a test for unnamed factory methods. |
| 961 | 880 |
| 962 var metadata = bazClass.metadata; | 881 var metadata = bazClass.metadata; |
| 963 Expect.isNotNull(metadata); | 882 Expect.isNotNull(metadata); |
| 964 Expect.equals(0, metadata.length); | 883 Expect.equals(0, metadata.length); |
| 965 } | 884 } |
| 966 | 885 |
| 967 // class _PrivateClass { | 886 // class _PrivateClass { |
| 968 // var _privateField; | 887 // var _privateField; |
| 969 // get _privateGetter => _privateField; | 888 // get _privateGetter => _privateField; |
| 970 // void set _privateSetter(value) => _privateField = value; | 889 // void set _privateSetter(value) => _privateField = value; |
| 971 // void _privateMethod() {} | 890 // void _privateMethod() {} |
| 972 // _PrivateClass._privateConstructor(); | 891 // _PrivateClass._privateConstructor(); |
| 973 // factory _PrivateClass._privateFactoryConstructor() => new _PrivateClass(); | 892 // factory _PrivateClass._privateFactoryConstructor() => new _PrivateClass(); |
| 974 // } | 893 // } |
| 975 void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, | 894 void testPrivate(MirrorSystem system, LibraryMirror helperLibrary, |
| 976 Map<String,TypeMirror> classes) { | 895 Map<Symbol, DeclarationMirror> declarations) { |
| 977 var privateClass = classes['_PrivateClass']; | 896 var privateClass = declarations[const Symbol('_PrivateClass')]; |
| 978 Expect.isNotNull(privateClass); | 897 Expect.isNotNull(privateClass); |
| 979 Expect.isTrue(privateClass is ClassMirror); | 898 Expect.isTrue(privateClass is ClassMirror); |
| 980 Expect.isTrue(privateClass.isClass); | |
| 981 Expect.isFalse(privateClass.isAbstract); | 899 Expect.isFalse(privateClass.isAbstract); |
| 982 Expect.isTrue(privateClass.isPrivate); | 900 Expect.isTrue(privateClass.isPrivate); |
| 983 | 901 |
| 984 var privateField = privateClass.members['_privateField']; | 902 var privateField = privateClass.declarations[const Symbol('_privateField')]; |
| 985 Expect.isNotNull(privateField); | 903 Expect.isNotNull(privateField); |
| 986 Expect.isTrue(privateField is VariableMirror); | 904 Expect.isTrue(privateField is VariableMirror); |
| 987 Expect.isTrue(privateField.isPrivate); | 905 Expect.isTrue(privateField.isPrivate); |
| 988 | 906 |
| 989 var privateGetter = privateClass.members['_privateGetter']; | 907 var privateGetter = privateClass.declarations[const Symbol('_privateGetter')]; |
| 990 Expect.isNotNull(privateGetter); | 908 Expect.isNotNull(privateGetter); |
| 991 Expect.isTrue(privateGetter is MethodMirror); | 909 Expect.isTrue(privateGetter is MethodMirror); |
| 992 Expect.isTrue(privateGetter.isGetter); | 910 Expect.isTrue(privateGetter.isGetter); |
| 993 Expect.isTrue(privateGetter.isPrivate); | 911 Expect.isTrue(privateGetter.isPrivate); |
| 994 Expect.isFalse(privateGetter.isRegularMethod); | 912 Expect.isFalse(privateGetter.isRegularMethod); |
| 995 | 913 |
| 996 var privateSetter = privateClass.members['_privateSetter=']; | 914 var privateSetter = |
| 915 privateClass.declarations[const Symbol('_privateSetter=')]; |
| 997 Expect.isNotNull(privateSetter); | 916 Expect.isNotNull(privateSetter); |
| 998 Expect.isTrue(privateSetter is MethodMirror); | 917 Expect.isTrue(privateSetter is MethodMirror); |
| 999 Expect.isTrue(privateSetter.isSetter); | 918 Expect.isTrue(privateSetter.isSetter); |
| 1000 Expect.isTrue(privateSetter.isPrivate); | 919 Expect.isTrue(privateSetter.isPrivate); |
| 1001 Expect.isFalse(privateSetter.isRegularMethod); | 920 Expect.isFalse(privateSetter.isRegularMethod); |
| 1002 | 921 |
| 1003 var privateMethod = privateClass.members['_privateMethod']; | 922 var privateMethod = privateClass.declarations[const Symbol('_privateMethod')]; |
| 1004 Expect.isNotNull(privateMethod); | 923 Expect.isNotNull(privateMethod); |
| 1005 Expect.isTrue(privateMethod is MethodMirror); | 924 Expect.isTrue(privateMethod is MethodMirror); |
| 1006 Expect.isTrue(privateMethod.isPrivate); | 925 Expect.isTrue(privateMethod.isPrivate); |
| 1007 Expect.isTrue(privateMethod.isRegularMethod); | 926 Expect.isTrue(privateMethod.isRegularMethod); |
| 1008 | 927 |
| 1009 var privateConstructor = | 928 var privateConstructor = |
| 1010 privateClass.members['_privateConstructor']; | 929 privateClass.declarations[const Symbol('_privateConstructor')]; |
| 1011 Expect.isNotNull(privateConstructor); | 930 Expect.isNotNull(privateConstructor); |
| 1012 Expect.isTrue(privateConstructor is MethodMirror); | 931 Expect.isTrue(privateConstructor is MethodMirror); |
| 1013 Expect.isTrue(privateConstructor.isConstructor); | 932 Expect.isTrue(privateConstructor.isConstructor); |
| 1014 Expect.isTrue(privateConstructor.isPrivate); | 933 Expect.isTrue(privateConstructor.isPrivate); |
| 1015 Expect.isFalse(privateConstructor.isConstConstructor); | 934 Expect.isFalse(privateConstructor.isConstConstructor); |
| 1016 Expect.isFalse(privateConstructor.isRedirectingConstructor); | 935 Expect.isFalse(privateConstructor.isRedirectingConstructor); |
| 1017 Expect.isTrue(privateConstructor.isGenerativeConstructor); | 936 Expect.isTrue(privateConstructor.isGenerativeConstructor); |
| 1018 Expect.isFalse(privateConstructor.isFactoryConstructor); | 937 Expect.isFalse(privateConstructor.isFactoryConstructor); |
| 1019 | 938 |
| 1020 var privateFactoryConstructor = | 939 var privateFactoryConstructor = |
| 1021 privateClass.members['_privateFactoryConstructor']; | 940 privateClass.declarations[const Symbol('_privateFactoryConstructor')]; |
| 1022 Expect.isNotNull(privateFactoryConstructor); | 941 Expect.isNotNull(privateFactoryConstructor); |
| 1023 Expect.isTrue(privateFactoryConstructor is MethodMirror); | 942 Expect.isTrue(privateFactoryConstructor is MethodMirror); |
| 1024 Expect.isTrue(privateFactoryConstructor.isConstructor); | 943 Expect.isTrue(privateFactoryConstructor.isConstructor); |
| 1025 Expect.isTrue(privateFactoryConstructor.isPrivate); | 944 Expect.isTrue(privateFactoryConstructor.isPrivate); |
| 1026 Expect.isFalse(privateFactoryConstructor.isConstConstructor); | 945 Expect.isFalse(privateFactoryConstructor.isConstConstructor); |
| 1027 Expect.isFalse(privateFactoryConstructor.isRedirectingConstructor); | 946 Expect.isFalse(privateFactoryConstructor.isRedirectingConstructor); |
| 1028 Expect.isFalse(privateFactoryConstructor.isGenerativeConstructor); | 947 Expect.isFalse(privateFactoryConstructor.isGenerativeConstructor); |
| 1029 Expect.isTrue(privateFactoryConstructor.isFactoryConstructor); | 948 Expect.isTrue(privateFactoryConstructor.isFactoryConstructor); |
| 1030 | 949 |
| 1031 var metadata = privateClass.metadata; | 950 var metadata = privateClass.metadata; |
| 1032 Expect.isNotNull(metadata); | 951 Expect.isNotNull(metadata); |
| 1033 Expect.equals(0, metadata.length); | 952 Expect.equals(0, metadata.length); |
| 1034 } | 953 } |
| OLD | NEW |