Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: dart/tests/lib/mirrors/metadata_test.dart

Issue 16101007: Implement LibraryMirror.metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix issues found during testing. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+ 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
+ // computed.
+ throw 'Bad constant: $symbol';
+ }
+ print(metadata);
+}

Powered by Google App Engine
This is Rietveld 408576698