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

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

Issue 16757007: Changes to mirrors in support of metadata access at runtime. Assumes VM changes in flight.… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/metadata_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/library_metadata_test.dart
===================================================================
--- tests/lib/mirrors/library_metadata_test.dart (revision 0)
+++ tests/lib/mirrors/library_metadata_test.dart (revision 0)
@@ -0,0 +1,45 @@
+// 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.
+
+@string @symbol
+library test.library_metadata_test;
+
+import 'dart:mirrors';
+
+const string = 'a metadata string';
+
+const symbol = const Symbol('symbol');
+
+const hest = 'hest';
+
+checkMetadata(DeclarationMirror mirror, List expectedMetadata) {
+ List metadata = mirror.metadata.map((m) => m.reflectee).toList();
+ if (metadata == null) {
+ throw 'Null metadata on $mirror';
+ }
+ int expectedLength = expectedMetadata.length;
+ int actualLength = metadata.length;
+ if (expectedLength != actualLength) {
+ throw 'Expected length = $expectedLength, but got length = $actualLength.';
+ }
+ for (int i = 0; i < expectedLength; i++) {
+ if (metadata[i] != expectedMetadata[i]) {
+ throw '${metadata[i]} is not "${expectedMetadata[i]}"'
+ ' in $mirror at index $i';
+ }
+ }
+ print(metadata);
+}
+
+main() {
+ if (MirrorSystem.getName(symbol) != 'symbol') {
+ // This happened in dart2js due to how early library metadata is
+ // computed.
+ throw 'Bad constant: $symbol';
+ }
+
+ MirrorSystem mirrors = currentMirrorSystem();
+ checkMetadata(mirrors.findLibrary(const Symbol('test.library_metadata_test')).first,
+ [string, symbol]);
+}
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698