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

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

Issue 67203002: Implement topLevelMembers, staticMembers, instanceMembers in the VM. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 stringifyClass(ClassMirror cls) { 99 stringifyClass(ClassMirror cls) {
100 var buffer = new StringBuffer(); 100 var buffer = new StringBuffer();
101 writeDeclarationOn(cls, buffer); 101 writeDeclarationOn(cls, buffer);
102 return 'Class($buffer)'; 102 return 'Class($buffer)';
103 } 103 }
104 104
105 stringifyMethod(MethodMirror method) { 105 stringifyMethod(MethodMirror method) {
106 var buffer = new StringBuffer(); 106 var buffer = new StringBuffer();
107 writeDeclarationOn(method, buffer); 107 writeDeclarationOn(method, buffer);
108 if (method.isAbstract) buffer.write(', abstract'); 108 if (method.isAbstract) buffer.write(', abstract');
109 if (method.isSynthetic) buffer.write(', synthetic');
109 if (method.isStatic) buffer.write(', static'); 110 if (method.isStatic) buffer.write(', static');
110 if (method.isGetter) buffer.write(', getter'); 111 if (method.isGetter) buffer.write(', getter');
111 if (method.isSetter) buffer.write(', setter'); 112 if (method.isSetter) buffer.write(', setter');
112 if (method.isConstructor) buffer.write(', constructor'); 113 if (method.isConstructor) buffer.write(', constructor');
113 return 'Method($buffer)'; 114 return 'Method($buffer)';
114 } 115 }
115 116
116 stringify(value) { 117 stringify(value) {
117 if (value is Map) return stringifyMap(value); 118 if (value is Map) return stringifyMap(value);
118 if (value is Iterable) return stringifyIterable(value); 119 if (value is Iterable) return stringifyIterable(value);
(...skipping 15 matching lines...) Expand all
134 Expect.stringEquals(expected, stringify(actual), reason); 135 Expect.stringEquals(expected, stringify(actual), reason);
135 } 136 }
136 137
137 compareSymbols(Symbol a, Symbol b) { 138 compareSymbols(Symbol a, Symbol b) {
138 return MirrorSystem.getName(a).compareTo(MirrorSystem.getName(b)); 139 return MirrorSystem.getName(a).compareTo(MirrorSystem.getName(b));
139 } 140 }
140 141
141 simpleNames(Iterable<Mirror> i) => i.map((e) => e.simpleName); 142 simpleNames(Iterable<Mirror> i) => i.map((e) => e.simpleName);
142 143
143 sort(Iterable<Symbol> symbols) => symbols.toList()..sort(compareSymbols); 144 sort(Iterable<Symbol> symbols) => symbols.toList()..sort(compareSymbols);
OLDNEW
« no previous file with comments | « tests/lib/mirrors/static_members_test.dart ('k') | tests/lib/mirrors/synthetic_accessor_properties_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698