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

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

Issue 154733003: Access to imports in the VM's runtime mirrors. Extend test coverage of the source mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: sync Created 6 years, 10 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/mirrors/library_imports_shown_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/stringify.dart
diff --git a/tests/lib/mirrors/stringify.dart b/tests/lib/mirrors/stringify.dart
index c848f93464587c6129a0c055ce8bfb8bc2d596ca..067769a1757f44a90e05cfde4b434f8aba34dfa6 100644
--- a/tests/lib/mirrors/stringify.dart
+++ b/tests/lib/mirrors/stringify.dart
@@ -114,6 +114,39 @@ stringifyMethod(MethodMirror method) {
return 'Method($buffer)';
}
+stringifyDependencies(LibraryMirror l) {
+ n(s) => s is Symbol ? MirrorSystem.getName(s) : s;
+ compareDep(a, b) =>
+ n(a.targetLibrary.simpleName).compareTo(n(b.targetLibrary.simpleName));
+ compareCom(a, b) => n(a.identifier).compareTo(n(b.identifier));
+ compareFirst(a, b) => a[0].compareTo(b[0]);
+ sortBy(c, p) => new List.from(c)..sort(p);
+
+ var buffer = new StringBuffer();
+ sortBy(l.libraryDependencies, compareDep).forEach((dep) {
+ if (dep.isImport) buffer.write('import ');
+ if (dep.isExport) buffer.write('export ');
+ buffer.write(n(dep.targetLibrary.simpleName));
+ if (dep.prefix != null) buffer.write(' as ${n(dep.prefix)}');
+ buffer.write('\n');
+
+ List flattenedCombinators = new List();
+ dep.combinators.forEach((com) {
+ com.identifiers.forEach((ident) {
+ flattenedCombinators.add([n(ident), com.isShow, com.isHide]);
+ });
+ });
+ sortBy(flattenedCombinators, compareFirst).forEach((triple) {
+ buffer.write(' ');
+ if (triple[1]) buffer.write('show ');
+ if (triple[2]) buffer.write('hide ');
+ buffer.write(triple[0]);
+ buffer.write('\n');
+ });
+ });
+ return buffer.toString();
+}
+
stringify(value) {
if (value is Map) return stringifyMap(value);
if (value is Iterable) return stringifyIterable(value);
« no previous file with comments | « tests/lib/mirrors/library_imports_shown_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698