| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 Expect.notEquals(testfoo, test_foo); | 57 Expect.notEquals(testfoo, test_foo); |
| 58 | 58 |
| 59 Expect.equals(test_foo, #_foo); | 59 Expect.equals(test_foo, #_foo); |
| 60 | 60 |
| 61 | 61 |
| 62 // Test interactions with the manglings for getters and setters, etc. | 62 // Test interactions with the manglings for getters and setters, etc. |
| 63 ClassMirror cm = reflectClass(_C); | 63 ClassMirror cm = reflectClass(_C); |
| 64 Expect.equals(#_C, cm.simpleName); | 64 Expect.equals(#_C, cm.simpleName); |
| 65 Expect.equals('_C', MirrorSystem.getName(cm.simpleName)); | 65 Expect.equals('_C', MirrorSystem.getName(cm.simpleName)); |
| 66 | 66 |
| 67 MethodMirror mm = cm.members[#g]; | 67 MethodMirror mm = cm.declarations[#g]; |
| 68 Expect.isNotNull(mm); | 68 Expect.isNotNull(mm); |
| 69 Expect.isTrue(mm.isGetter); | 69 Expect.isTrue(mm.isGetter); |
| 70 Expect.equals(#g, mm.simpleName); | 70 Expect.equals(#g, mm.simpleName); |
| 71 Expect.equals('g', MirrorSystem.getName(mm.simpleName)); | 71 Expect.equals('g', MirrorSystem.getName(mm.simpleName)); |
| 72 | 72 |
| 73 mm = cm.members[const Symbol('s=')]; | 73 mm = cm.declarations[const Symbol('s=')]; |
| 74 Expect.isNotNull(mm); | 74 Expect.isNotNull(mm); |
| 75 Expect.isTrue(mm.isSetter); | 75 Expect.isTrue(mm.isSetter); |
| 76 Expect.equals(const Symbol('s='), mm.simpleName); | 76 Expect.equals(const Symbol('s='), mm.simpleName); |
| 77 Expect.equals('s=', MirrorSystem.getName(mm.simpleName)); | 77 Expect.equals('s=', MirrorSystem.getName(mm.simpleName)); |
| 78 | 78 |
| 79 mm = cm.members[#m]; | 79 mm = cm.declarations[#m]; |
| 80 Expect.isNotNull(mm); | 80 Expect.isNotNull(mm); |
| 81 Expect.isTrue(mm.isRegularMethod); | 81 Expect.isTrue(mm.isRegularMethod); |
| 82 Expect.equals(#m, mm.simpleName); | 82 Expect.equals(#m, mm.simpleName); |
| 83 Expect.equals('m', MirrorSystem.getName(mm.simpleName)); | 83 Expect.equals('m', MirrorSystem.getName(mm.simpleName)); |
| 84 | 84 |
| 85 mm = cm.members[#_g]; | 85 mm = cm.declarations[#_g]; |
| 86 Expect.isNotNull(mm); | 86 Expect.isNotNull(mm); |
| 87 Expect.isTrue(mm.isGetter); | 87 Expect.isTrue(mm.isGetter); |
| 88 Expect.equals(#_g, mm.simpleName); | 88 Expect.equals(#_g, mm.simpleName); |
| 89 Expect.equals('_g', MirrorSystem.getName(mm.simpleName)); | 89 Expect.equals('_g', MirrorSystem.getName(mm.simpleName)); |
| 90 | 90 |
| 91 mm = cm.members[MirrorSystem.getSymbol('_s=', libtest)]; | 91 mm = cm.declarations[MirrorSystem.getSymbol('_s=', libtest)]; |
| 92 Expect.isNotNull(mm); | 92 Expect.isNotNull(mm); |
| 93 Expect.isTrue(mm.isSetter); | 93 Expect.isTrue(mm.isSetter); |
| 94 Expect.equals(MirrorSystem.getSymbol('_s=', libtest), mm.simpleName); | 94 Expect.equals(MirrorSystem.getSymbol('_s=', libtest), mm.simpleName); |
| 95 Expect.equals('_s=', MirrorSystem.getName(mm.simpleName)); | 95 Expect.equals('_s=', MirrorSystem.getName(mm.simpleName)); |
| 96 | 96 |
| 97 mm = cm.members[#_m]; | 97 mm = cm.declarations[#_m]; |
| 98 Expect.isNotNull(mm); | 98 Expect.isNotNull(mm); |
| 99 Expect.isTrue(mm.isRegularMethod); | 99 Expect.isTrue(mm.isRegularMethod); |
| 100 Expect.equals(#_m, mm.simpleName); | 100 Expect.equals(#_m, mm.simpleName); |
| 101 Expect.equals('_m', MirrorSystem.getName(mm.simpleName)); | 101 Expect.equals('_m', MirrorSystem.getName(mm.simpleName)); |
| 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] as MethodMirror).parameters[0]; | 112 ParameterMirror pm = (cm.declarations[#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 |