| 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/source_mirror
s.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/analyze.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' |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 Expect.isTrue(fooClass.typeArguments.isEmpty); | 148 Expect.isTrue(fooClass.typeArguments.isEmpty); |
| 149 var fooClassTypeVariables = fooClass.typeVariables; | 149 var fooClassTypeVariables = fooClass.typeVariables; |
| 150 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); | 150 Expect.isNotNull(fooClassTypeVariables, "Type variable list is null"); |
| 151 Expect.isTrue(fooClassTypeVariables.isEmpty, | 151 Expect.isTrue(fooClassTypeVariables.isEmpty, |
| 152 "Type variable list is not empty"); | 152 "Type variable list is not empty"); |
| 153 | 153 |
| 154 var fooClassMembers = fooClass.declarations; | 154 var fooClassMembers = fooClass.declarations; |
| 155 Expect.isNotNull(fooClassMembers, "Declared members map is null"); | 155 Expect.isNotNull(fooClassMembers, "Declared members map is null"); |
| 156 Expect.isTrue(fooClassMembers.isEmpty, "Declared members map is unempty"); | 156 Expect.equals(1, fooClassMembers.length); |
| 157 |
| 158 var fooM = fooClassMembers[#m]; |
| 159 Expect.isNotNull(fooM); |
| 160 Expect.isTrue(fooM is MethodMirror); |
| 161 Expect.equals(1, fooM.parameters.length); |
| 162 var fooMa = fooM.parameters[0]; |
| 163 Expect.isNotNull(fooMa); |
| 164 Expect.isTrue(fooMa is ParameterMirror); |
| 157 | 165 |
| 158 ////////////////////////////////////////////////////////////////////////////// | 166 ////////////////////////////////////////////////////////////////////////////// |
| 159 // Metadata tests | 167 // Metadata tests |
| 160 ////////////////////////////////////////////////////////////////////////////// | 168 ////////////////////////////////////////////////////////////////////////////// |
| 161 | 169 |
| 162 var metadataList = fooClass.metadata; | 170 var metadataList = fooClass.metadata; |
| 163 Expect.isNotNull(metadataList); | 171 Expect.isNotNull(metadataList); |
| 164 Expect.equals(16, metadataList.length); | 172 Expect.equals(16, metadataList.length); |
| 165 var metadataListIndex = 0; | 173 var metadataListIndex = 0; |
| 166 var metadata; | 174 var metadata; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 var it = mapData.keys.iterator; | 338 var it = mapData.keys.iterator; |
| 331 Expect.isTrue(it.moveNext()); | 339 Expect.isTrue(it.moveNext()); |
| 332 Expect.stringEquals('foo', it.current); | 340 Expect.stringEquals('foo', it.current); |
| 333 element = mapData.getValue('foo'); | 341 element = mapData.getValue('foo'); |
| 334 Expect.isNotNull(element); | 342 Expect.isNotNull(element); |
| 335 Expect.isTrue(element.hasReflectee); | 343 Expect.isTrue(element.hasReflectee); |
| 336 Expect.stringEquals("Foo", element.reflectee); | 344 Expect.stringEquals("Foo", element.reflectee); |
| 337 Expect.isNull(mapData.getValue('bar')); | 345 Expect.isNull(mapData.getValue('bar')); |
| 338 | 346 |
| 339 // @metadata | 347 // @metadata |
| 340 metadata = metadataList[metadataListIndex++]; | 348 var metadataRef = metadata = metadataList[metadataListIndex++]; |
| 341 Expect.isTrue(metadata is InstanceMirror); | 349 Expect.isTrue(metadata is InstanceMirror); |
| 342 Expect.isFalse(metadata.hasReflectee); | 350 Expect.isFalse(metadata.hasReflectee); |
| 343 Expect.throws(() => metadata.reflectee, (_) => true); | 351 Expect.throws(() => metadata.reflectee, (_) => true); |
| 344 Expect.equals(metadataType.originalDeclaration, metadata.type); | 352 Expect.equals(metadataType.originalDeclaration, metadata.type); |
| 345 data = metadata.getField(#data); | 353 data = metadata.getField(#data); |
| 346 Expect.isNotNull(data); | 354 Expect.isNotNull(data); |
| 347 Expect.isTrue(data.hasReflectee); | 355 Expect.isTrue(data.hasReflectee); |
| 348 Expect.isNull(data.reflectee); | 356 Expect.isNull(data.reflectee); |
| 349 | 357 |
| 350 // /** Multiline doc comment. */ | 358 // /** Multiline doc comment. */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 368 Expect.isTrue(metadata is CommentInstanceMirror); | 376 Expect.isTrue(metadata is CommentInstanceMirror); |
| 369 Expect.equals(commentType.originalDeclaration, metadata.type); | 377 Expect.equals(commentType.originalDeclaration, metadata.type); |
| 370 Expect.isFalse(metadata.isDocComment); | 378 Expect.isFalse(metadata.isDocComment); |
| 371 Expect.stringEquals( | 379 Expect.stringEquals( |
| 372 "/* Multiline comment. */", metadata.text); | 380 "/* Multiline comment. */", metadata.text); |
| 373 Expect.stringEquals( | 381 Expect.stringEquals( |
| 374 "Multiline comment. ", metadata.trimmedText); | 382 "Multiline comment. ", metadata.trimmedText); |
| 375 | 383 |
| 376 Expect.equals(metadataList.length, metadataListIndex); | 384 Expect.equals(metadataList.length, metadataListIndex); |
| 377 | 385 |
| 386 Expect.isNotNull(fooMa.metadata); |
| 387 Expect.equals(1, fooMa.metadata.length); |
| 388 Expect.equals(metadataRef, fooMa.metadata[0]); |
| 389 |
| 378 ////////////////////////////////////////////////////////////////////////////// | 390 ////////////////////////////////////////////////////////////////////////////// |
| 379 // Location test | 391 // Location test |
| 380 ////////////////////////////////////////////////////////////////////////////// | 392 ////////////////////////////////////////////////////////////////////////////// |
| 381 | 393 |
| 382 var fooClassLocation = fooClass.location; | 394 var fooClassLocation = fooClass.location; |
| 383 Expect.isNotNull(fooClassLocation); | 395 Expect.isNotNull(fooClassLocation); |
| 384 // Expect the location to start with the first metadata, not including the | 396 // Expect the location to start with the first metadata, not including the |
| 385 // leading comment. | 397 // leading comment. |
| 386 Expect.equals(376, fooClassLocation.offset, "Unexpected offset"); | 398 Expect.equals(376, fooClassLocation.offset, "Unexpected offset"); |
| 387 // Expect the location to end with the class body. | 399 // Expect the location to end with the class body. |
| 388 Expect.equals(332, fooClassLocation.length, "Unexpected length"); | 400 Expect.equals(351, fooClassLocation.length, "Unexpected length"); |
| 389 Expect.equals(18, fooClassLocation.line, "Unexpected line"); | 401 Expect.equals(18, fooClassLocation.line, "Unexpected line"); |
| 390 Expect.equals(1, fooClassLocation.column, "Unexpected column"); | 402 Expect.equals(1, fooClassLocation.column, "Unexpected column"); |
| 391 | 403 |
| 392 } | 404 } |
| 393 | 405 |
| 394 // Testing abstract class Bar: | 406 // Testing abstract class Bar: |
| 395 // | 407 // |
| 396 // abstract class Bar<E> { | 408 // abstract class Bar<E> { |
| 397 // | 409 // |
| 398 // } | 410 // } |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 Expect.isTrue(privateFactoryConstructor.isPrivate); | 956 Expect.isTrue(privateFactoryConstructor.isPrivate); |
| 945 Expect.isFalse(privateFactoryConstructor.isConstConstructor); | 957 Expect.isFalse(privateFactoryConstructor.isConstConstructor); |
| 946 Expect.isFalse(privateFactoryConstructor.isRedirectingConstructor); | 958 Expect.isFalse(privateFactoryConstructor.isRedirectingConstructor); |
| 947 Expect.isFalse(privateFactoryConstructor.isGenerativeConstructor); | 959 Expect.isFalse(privateFactoryConstructor.isGenerativeConstructor); |
| 948 Expect.isTrue(privateFactoryConstructor.isFactoryConstructor); | 960 Expect.isTrue(privateFactoryConstructor.isFactoryConstructor); |
| 949 | 961 |
| 950 var metadata = privateClass.metadata; | 962 var metadata = privateClass.metadata; |
| 951 Expect.isNotNull(metadata); | 963 Expect.isNotNull(metadata); |
| 952 Expect.equals(0, metadata.length); | 964 Expect.equals(0, metadata.length); |
| 953 } | 965 } |
| OLD | NEW |