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

Side by Side Diff: tests/lib/mirrors/stringify.dart

Issue 921163004: Add LibraryDependencyMirror.isDeferred. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Helper methods for converting a [Mirror] to a [String]. 5 /// Helper methods for converting a [Mirror] to a [String].
6 library test.stringify; 6 library test.stringify;
7 7
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 9
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 n(a.targetLibrary.simpleName).compareTo(n(b.targetLibrary.simpleName)); 120 n(a.targetLibrary.simpleName).compareTo(n(b.targetLibrary.simpleName));
121 compareCom(a, b) => n(a.identifier).compareTo(n(b.identifier)); 121 compareCom(a, b) => n(a.identifier).compareTo(n(b.identifier));
122 compareFirst(a, b) => a[0].compareTo(b[0]); 122 compareFirst(a, b) => a[0].compareTo(b[0]);
123 sortBy(c, p) => new List.from(c)..sort(p); 123 sortBy(c, p) => new List.from(c)..sort(p);
124 124
125 var buffer = new StringBuffer(); 125 var buffer = new StringBuffer();
126 sortBy(l.libraryDependencies, compareDep).forEach((dep) { 126 sortBy(l.libraryDependencies, compareDep).forEach((dep) {
127 if (dep.isImport) buffer.write('import '); 127 if (dep.isImport) buffer.write('import ');
128 if (dep.isExport) buffer.write('export '); 128 if (dep.isExport) buffer.write('export ');
129 buffer.write(n(dep.targetLibrary.simpleName)); 129 buffer.write(n(dep.targetLibrary.simpleName));
130 if (dep.isDeferred) buffer.write(' deferred');
130 if (dep.prefix != null) buffer.write(' as ${n(dep.prefix)}'); 131 if (dep.prefix != null) buffer.write(' as ${n(dep.prefix)}');
131 buffer.write('\n'); 132 buffer.write('\n');
132 133
133 List flattenedCombinators = new List(); 134 List flattenedCombinators = new List();
134 dep.combinators.forEach((com) { 135 dep.combinators.forEach((com) {
135 com.identifiers.forEach((ident) { 136 com.identifiers.forEach((ident) {
136 flattenedCombinators.add([n(ident), com.isShow, com.isHide]); 137 flattenedCombinators.add([n(ident), com.isShow, com.isHide]);
137 }); 138 });
138 }); 139 });
139 sortBy(flattenedCombinators, compareFirst).forEach((triple) { 140 sortBy(flattenedCombinators, compareFirst).forEach((triple) {
(...skipping 28 matching lines...) Expand all
168 Expect.stringEquals(expected, stringify(actual), reason); 169 Expect.stringEquals(expected, stringify(actual), reason);
169 } 170 }
170 171
171 compareSymbols(Symbol a, Symbol b) { 172 compareSymbols(Symbol a, Symbol b) {
172 return MirrorSystem.getName(a).compareTo(MirrorSystem.getName(b)); 173 return MirrorSystem.getName(a).compareTo(MirrorSystem.getName(b));
173 } 174 }
174 175
175 simpleNames(Iterable<Mirror> i) => i.map((e) => e.simpleName); 176 simpleNames(Iterable<Mirror> i) => i.map((e) => e.simpleName);
176 177
177 sort(Iterable<Symbol> symbols) => symbols.toList()..sort(compareSymbols); 178 sort(Iterable<Symbol> symbols) => symbols.toList()..sort(compareSymbols);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698