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

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

Issue 15821011: Implement ClassMirror.metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 9bbee5a857076860f4945235575322bf9505dd45..973bf34ff7906ec952a05aca85f611c0b772f395 100644
--- a/dart/tests/lib/mirrors/metadata_test.dart
+++ b/dart/tests/lib/mirrors/metadata_test.dart
@@ -11,24 +11,38 @@ 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';
+@symbol @fisk
+class MyClass {
+}
+
+checkMetadata(DeclarationMirror mirror, List expectedMetadata) {
+ List metadata = mirror.metadata.map((m) => m.reflectee).toList();
+ if (metadata == null) {
+ throw 'Null metadata on $mirror';
}
- if (!metadata.contains(fisk)) {
- throw '$metadata does not contain "$fisk"';
+ int expectedLength = expectedMetadata.length;
+ int actualLength = metadata.length;
+ if (expectedLength != actualLength) {
+ throw 'Expected length = $expectedLength, but got length = $actualLength.';
}
- if (!metadata.contains(symbol)) {
- throw '$metadata does not contain "$symbol"';
+ 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) != 'fisk') {
// This happened in dart2js due to how early library metadata is
// computed.
throw 'Bad constant: $symbol';
}
- print(metadata);
+
+ MirrorSystem mirrors = currentMirrorSystem();
+ checkMetadata(mirrors.findLibrary(const Symbol('test.metadata_test')).first,
+ [fisk, symbol]);
+ checkMetadata(reflect(new MyClass()).type, [symbol, fisk]);
}
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698