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; | 5 library test; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 typedef int _F(int); | 10 typedef int _F(int); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 TypeVariableMirror tvm = cm.typeVariables[0]; | 103 TypeVariableMirror tvm = cm.typeVariables[0]; |
104 Expect.isNotNull(tvm); | 104 Expect.isNotNull(tvm); |
105 Expect.equals(#_T, tvm.simpleName); | 105 Expect.equals(#_T, tvm.simpleName); |
106 Expect.equals('_T', MirrorSystem.getName(tvm.simpleName)); | 106 Expect.equals('_T', MirrorSystem.getName(tvm.simpleName)); |
107 | 107 |
108 TypedefMirror tdm = reflectType(_F); | 108 TypedefMirror tdm = reflectType(_F); |
109 Expect.equals(#_F, tdm.simpleName); | 109 Expect.equals(#_F, tdm.simpleName); |
110 Expect.equals('_F', MirrorSystem.getName(tdm.simpleName)); | 110 Expect.equals('_F', MirrorSystem.getName(tdm.simpleName)); |
111 | 111 |
112 ParameterMirror pm = cm.members[#m].parameters[0]; | 112 ParameterMirror pm = (cm.members[#m] as MethodMirror).parameters[0]; |
113 Expect.equals(#_p, pm.simpleName); | 113 Expect.equals(#_p, pm.simpleName); |
114 Expect.equals('_p', MirrorSystem.getName(pm.simpleName)); | 114 Expect.equals('_p', MirrorSystem.getName(pm.simpleName)); |
115 | 115 |
116 | 116 |
117 // Private symbol without a library. | 117 // Private symbol without a library. |
118 Expect.throws(() => MirrorSystem.getSymbol('_private'), | 118 Expect.throws(() => MirrorSystem.getSymbol('_private'), |
119 (e) => e is ArgumentError); | 119 (e) => e is ArgumentError); |
120 | 120 |
121 var notALibraryMirror = 7; | 121 var notALibraryMirror = 7; |
122 Expect.throws(() => MirrorSystem.getSymbol('_private', notALibraryMirror), | 122 Expect.throws(() => MirrorSystem.getSymbol('_private', notALibraryMirror), |
123 (e) => e is ArgumentError || e is TypeError); | 123 (e) => e is ArgumentError || e is TypeError); |
124 | 124 |
125 Expect.throws(() => MirrorSystem.getSymbol('public', notALibraryMirror), | 125 Expect.throws(() => MirrorSystem.getSymbol('public', notALibraryMirror), |
126 (e) => e is ArgumentError || e is TypeError); | 126 (e) => e is ArgumentError || e is TypeError); |
127 } | 127 } |
OLD | NEW |