OLD | NEW |
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 library test.reflect_model_test; | 5 library test.reflect_model_test; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 if (variable.isFinal) buffer.write(', final'); | 48 if (variable.isFinal) buffer.write(', final'); |
49 return (buffer..write(')')).toString(); | 49 return (buffer..write(')')).toString(); |
50 } | 50 } |
51 | 51 |
52 stringifyMethod(MethodMirror method) { | 52 stringifyMethod(MethodMirror method) { |
53 var buffer = new StringBuffer('Method('); | 53 var buffer = new StringBuffer('Method('); |
54 writeDeclarationOn(method, buffer); | 54 writeDeclarationOn(method, buffer); |
55 if (method.isStatic) buffer.write(', static'); | 55 if (method.isStatic) buffer.write(', static'); |
56 if (method.isGetter) buffer.write(', getter'); | 56 if (method.isGetter) buffer.write(', getter'); |
57 if (method.isSetter) buffer.write(', setter'); | 57 if (method.isSetter) buffer.write(', setter'); |
| 58 if (method.isConstructor) buffer.write(', constructor'); |
58 return (buffer..write(')')).toString(); | 59 return (buffer..write(')')).toString(); |
59 } | 60 } |
60 | 61 |
61 stringify(value) { | 62 stringify(value) { |
62 if (value is Map) return stringifyMap(value); | 63 if (value is Map) return stringifyMap(value); |
63 if (value is VariableMirror) return stringifyVariable(value); | 64 if (value is VariableMirror) return stringifyVariable(value); |
64 if (value is MethodMirror) return stringifyMethod(value); | 65 if (value is MethodMirror) return stringifyMethod(value); |
65 if (value is Symbol) return stringifySymbol(value); | 66 if (value is Symbol) return stringifySymbol(value); |
66 if (value == null) return '<null>'; | 67 if (value == null) return '<null>'; |
67 throw 'Unexpected value: $value'; | 68 throw 'Unexpected value: $value'; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 Expect.equals('aMethod', c.invoke(aMethod, []).reflectee); | 161 Expect.equals('aMethod', c.invoke(aMethod, []).reflectee); |
161 | 162 |
162 Expect.throws(() { a.invoke(bMethod, []); }, isNoSuchMethodError); | 163 Expect.throws(() { a.invoke(bMethod, []); }, isNoSuchMethodError); |
163 Expect.equals('bMethod', b.invoke(bMethod, []).reflectee); | 164 Expect.equals('bMethod', b.invoke(bMethod, []).reflectee); |
164 Expect.equals('bMethod', c.invoke(bMethod, []).reflectee); | 165 Expect.equals('bMethod', c.invoke(bMethod, []).reflectee); |
165 | 166 |
166 Expect.throws(() { a.invoke(cMethod, []); }, isNoSuchMethodError); | 167 Expect.throws(() { a.invoke(cMethod, []); }, isNoSuchMethodError); |
167 Expect.throws(() { b.invoke(cMethod, []); }, isNoSuchMethodError); | 168 Expect.throws(() { b.invoke(cMethod, []); }, isNoSuchMethodError); |
168 Expect.equals('cMethod', c.invoke(cMethod, []).reflectee); | 169 Expect.equals('cMethod', c.invoke(cMethod, []).reflectee); |
169 } | 170 } |
OLD | NEW |