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 i); | 10 typedef int _F(int i); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 Expect.notEquals(core_foo, math_foo); | 57 Expect.notEquals(core_foo, math_foo); |
58 Expect.notEquals(math_foo, test_foo); | 58 Expect.notEquals(math_foo, test_foo); |
59 Expect.notEquals(test_foo, core_foo); | 59 Expect.notEquals(test_foo, core_foo); |
60 | 60 |
61 Expect.notEquals(corefoo, core_foo); | 61 Expect.notEquals(corefoo, core_foo); |
62 Expect.notEquals(mathfoo, math_foo); | 62 Expect.notEquals(mathfoo, math_foo); |
63 Expect.notEquals(testfoo, test_foo); | 63 Expect.notEquals(testfoo, test_foo); |
64 | 64 |
65 Expect.equals(test_foo, #_foo); | 65 Expect.equals(test_foo, #_foo); |
66 | 66 |
67 | |
68 // Test interactions with the manglings for getters and setters, etc. | 67 // Test interactions with the manglings for getters and setters, etc. |
69 ClassMirror cm = reflectClass(_C); | 68 ClassMirror cm = reflectClass(_C); |
70 Expect.equals(#_C, cm.simpleName); | 69 Expect.equals(#_C, cm.simpleName); |
71 Expect.equals('_C', MirrorSystem.getName(cm.simpleName)); | 70 Expect.equals('_C', MirrorSystem.getName(cm.simpleName)); |
72 | 71 |
73 MethodMirror mm = cm.declarations[#g]; | 72 MethodMirror mm = cm.declarations[#g]; |
74 Expect.isNotNull(mm); | 73 Expect.isNotNull(mm); |
75 Expect.isTrue(mm.isGetter); | 74 Expect.isTrue(mm.isGetter); |
76 Expect.equals(#g, mm.simpleName); | 75 Expect.equals(#g, mm.simpleName); |
77 Expect.equals('g', MirrorSystem.getName(mm.simpleName)); | 76 Expect.equals('g', MirrorSystem.getName(mm.simpleName)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 Expect.equals('_T', MirrorSystem.getName(tvm.simpleName)); | 111 Expect.equals('_T', MirrorSystem.getName(tvm.simpleName)); |
113 | 112 |
114 TypedefMirror tdm = reflectType(_F); | 113 TypedefMirror tdm = reflectType(_F); |
115 Expect.equals(#_F, tdm.simpleName); | 114 Expect.equals(#_F, tdm.simpleName); |
116 Expect.equals('_F', MirrorSystem.getName(tdm.simpleName)); | 115 Expect.equals('_F', MirrorSystem.getName(tdm.simpleName)); |
117 | 116 |
118 ParameterMirror pm = (cm.declarations[#m] as MethodMirror).parameters[0]; | 117 ParameterMirror pm = (cm.declarations[#m] as MethodMirror).parameters[0]; |
119 Expect.equals(#_p, pm.simpleName); | 118 Expect.equals(#_p, pm.simpleName); |
120 Expect.equals('_p', MirrorSystem.getName(pm.simpleName)); | 119 Expect.equals('_p', MirrorSystem.getName(pm.simpleName)); |
121 | 120 |
122 | |
123 // Private symbol without a library. | 121 // Private symbol without a library. |
124 Expect.throws(() => MirrorSystem.getSymbol('_private'), | 122 Expect.throws( |
125 (e) => e is ArgumentError); | 123 () => MirrorSystem.getSymbol('_private'), (e) => e is ArgumentError); |
126 | 124 |
127 var notALibraryMirror = 7; | 125 var notALibraryMirror = 7; |
128 Expect.throws(() => MirrorSystem.getSymbol('_private', notALibraryMirror), | 126 Expect.throws(() => MirrorSystem.getSymbol('_private', notALibraryMirror), |
129 (e) => e is ArgumentError || e is TypeError); | 127 (e) => e is ArgumentError || e is TypeError); |
130 | 128 |
131 Expect.throws(() => MirrorSystem.getSymbol('public', notALibraryMirror), | 129 Expect.throws(() => MirrorSystem.getSymbol('public', notALibraryMirror), |
132 (e) => e is ArgumentError || e is TypeError); | 130 (e) => e is ArgumentError || e is TypeError); |
133 } | 131 } |
OLD | NEW |