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

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

Issue 21624006: ParameterMirror: Implement some missing getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 var buffer = new StringBuffer(); 59 var buffer = new StringBuffer();
60 writeVariableOn(variable, buffer); 60 writeVariableOn(variable, buffer);
61 return 'Variable($buffer)'; 61 return 'Variable($buffer)';
62 } 62 }
63 63
64 stringifyParameter(ParameterMirror parameter) { 64 stringifyParameter(ParameterMirror parameter) {
65 var buffer = new StringBuffer(); 65 var buffer = new StringBuffer();
66 writeVariableOn(parameter, buffer); 66 writeVariableOn(parameter, buffer);
67 if (parameter.isOptional) buffer.write(', optional'); 67 if (parameter.isOptional) buffer.write(', optional');
68 if (parameter.isNamed) buffer.write(', named'); 68 if (parameter.isNamed) buffer.write(', named');
69 if (parameter.hasDefaultValue) { 69 // TODO(6490,12430): Add this check as soon as it's properly implemented in
70 buffer.write(', value = ${stringify(parameter.defaultValue)}'); 70 // the VM and dart2js.
71 } 71 // if (parameter.hasDefaultValue) {
72 // buffer.write(', value = ${stringify(parameter.defaultValue)}');
73 // }
72 // TODO(ahe): Move to writeVariableOn. 74 // TODO(ahe): Move to writeVariableOn.
73 buffer.write(', type = ${stringify(parameter.type)}'); 75 buffer.write(', type = ${stringify(parameter.type)}');
74 return 'Parameter($buffer)'; 76 return 'Parameter($buffer)';
75 } 77 }
76 78
77 stringifyType(TypeMirror type) { 79 stringifyType(TypeMirror type) {
78 var buffer = new StringBuffer(); 80 var buffer = new StringBuffer();
79 writeDeclarationOn(type, buffer); 81 writeDeclarationOn(type, buffer);
80 return 'Type($buffer)'; 82 return 'Type($buffer)';
81 } 83 }
(...skipping 25 matching lines...) Expand all
107 if (value is TypeMirror) return stringifyType(value); 109 if (value is TypeMirror) return stringifyType(value);
108 if (value == null) return '<null>'; 110 if (value == null) return '<null>';
109 throw 'Unexpected value: $value'; 111 throw 'Unexpected value: $value';
110 } 112 }
111 113
112 expect(expected, actual) => Expect.stringEquals(expected, stringify(actual)); 114 expect(expected, actual) => Expect.stringEquals(expected, stringify(actual));
113 115
114 compareSymbols(Symbol a, Symbol b) { 116 compareSymbols(Symbol a, Symbol b) {
115 return MirrorSystem.getName(a).compareTo(MirrorSystem.getName(b)); 117 return MirrorSystem.getName(a).compareTo(MirrorSystem.getName(b));
116 } 118 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698