Chromium Code Reviews| Index: dart/tests/lib/mirrors/metadata_test.dart |
| diff --git a/dart/tests/lib/mirrors/metadata_test.dart b/dart/tests/lib/mirrors/metadata_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9bbee5a857076860f4945235575322bf9505dd45 |
| --- /dev/null |
| +++ b/dart/tests/lib/mirrors/metadata_test.dart |
| @@ -0,0 +1,34 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +@fisk @symbol |
| +library test.metadata_test; |
| + |
| +import 'dart:mirrors'; |
| + |
| +const fisk = 'a metadata string'; |
| + |
| +const symbol = const Symbol('fisk'); |
| + |
| +main() { |
| + MirrorSystem mirrors = currentMirrorSystem(); |
| + LibraryMirror library = |
| + mirrors.findLibrary(const Symbol('test.metadata_test')).first; |
|
kasperl
2013/05/29 06:25:06
Should findLibrary be renamed? It would be easier
ahe
2013/05/29 06:40:28
That's a good suggestion.
ahe
2013/05/30 11:41:15
Filed bug: http://dartbug.com/10958
|
| + List metadata = library.metadata.map((m) => m.reflectee).toList(); |
| + if (metadata.length != 2) { |
| + throw 'Expected two pieces of metadata on library'; |
| + } |
| + if (!metadata.contains(fisk)) { |
| + throw '$metadata does not contain "$fisk"'; |
| + } |
| + if (!metadata.contains(symbol)) { |
| + throw '$metadata does not contain "$symbol"'; |
| + } |
| + if (MirrorSystem.getName(symbol) != 'fisk') { |
| + // This happened in dart2js due to how early library metadata is |
|
kasperl
2013/05/29 06:25:06
This happened? I guess this is a regression test f
ahe
2013/05/29 06:40:28
It is not really a regression test. I inspected t
|
| + // computed. |
| + throw 'Bad constant: $symbol'; |
| + } |
| + print(metadata); |
|
kasperl
2013/05/29 06:25:06
Intentional?
ahe
2013/05/29 06:40:28
Yeah. I distrust tests that don't produce output.
|
| +} |