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); |