OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 @fisk @symbol |
| 6 library test.metadata_test; |
| 7 |
| 8 import 'dart:mirrors'; |
| 9 |
| 10 const fisk = 'a metadata string'; |
| 11 |
| 12 const symbol = const Symbol('fisk'); |
| 13 |
| 14 main() { |
| 15 MirrorSystem mirrors = currentMirrorSystem(); |
| 16 LibraryMirror library = |
| 17 mirrors.findLibrary(const Symbol('test.metadata_test')).first; |
| 18 List metadata = library.metadata.map((m) => m.reflectee).toList(); |
| 19 if (metadata.length != 2) { |
| 20 throw 'Expected two pieces of metadata on library'; |
| 21 } |
| 22 if (!metadata.contains(fisk)) { |
| 23 throw '$metadata does not contain "$fisk"'; |
| 24 } |
| 25 if (!metadata.contains(symbol)) { |
| 26 throw '$metadata does not contain "$symbol"'; |
| 27 } |
| 28 if (MirrorSystem.getName(symbol) != 'fisk') { |
| 29 // This happened in dart2js due to how early library metadata is |
| 30 // computed. |
| 31 throw 'Bad constant: $symbol'; |
| 32 } |
| 33 print(metadata); |
| 34 } |
OLD | NEW |