OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.mirrors_nsm_mistatch; | 5 library test.mirrors_nsm_mismatch; |
6 | 6 |
| 7 @MirrorsUsed(targets: "test.mirrors_nsm_mismatch") |
7 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
8 import 'mirrors_nsm_test.dart'; | 9 import 'mirrors_nsm_test.dart'; |
9 | 10 |
10 topLevelMethod({missing}) {} | 11 topLevelMethod({missing}) {} |
11 class C { | 12 class C { |
12 C.constructor({missing}); | 13 C.constructor({missing}); |
13 factory C.redirecting({missing}) = C.constructor; | 14 factory C.redirecting({missing}) = C.constructor; |
14 static staticMethod({missing}) {} | 15 static staticMethod({missing}) {} |
15 instanceMethod({missing}) {} | 16 instanceMethod({missing}) {} |
16 } | 17 } |
17 | 18 |
18 main() { | 19 main() { |
19 var mirrors = currentMirrorSystem(); | 20 var mirrors = currentMirrorSystem(); |
20 var libMirror = mirrors.findLibrary(#test.mirrors_nsm_mistatch); | 21 var libMirror = mirrors.findLibrary(#test.mirrors_nsm_mismatch); |
21 expectMatchingErrors(() => libMirror.invoke(#topLevelMethod, [], {#extra: 1}), | 22 expectMatchingErrors(() => libMirror.invoke(#topLevelMethod, [], {#extra: 1}), |
22 () => topLevelMethod(extra: 1)); | 23 () => topLevelMethod(extra: 1)); |
23 expectMatchingErrors(() => libMirror.invoke(#topLevelMethod, ['positional']), | 24 expectMatchingErrors(() => libMirror.invoke(#topLevelMethod, ['positional']), |
24 () => topLevelMethod('positional')); | 25 () => topLevelMethod('positional')); |
25 | 26 |
26 var classMirror = reflectClass(C); | 27 var classMirror = reflectClass(C); |
27 expectMatchingErrors(() => classMirror.newInstance(#constructor, [], | 28 expectMatchingErrors(() => classMirror.newInstance(#constructor, [], |
28 {#extra: 1}), | 29 {#extra: 1}), |
29 () => new C.constructor(extra: 1)); | 30 () => new C.constructor(extra: 1)); |
30 expectMatchingErrors(() => classMirror.newInstance(#redirecting, [], | 31 expectMatchingErrors(() => classMirror.newInstance(#redirecting, [], |
(...skipping 14 matching lines...) Expand all Loading... |
45 | 46 |
46 var instanceMirror = reflect(new C.constructor()); | 47 var instanceMirror = reflect(new C.constructor()); |
47 expectMatchingErrors(() => instanceMirror.invoke(#instanceMethod, [], | 48 expectMatchingErrors(() => instanceMirror.invoke(#instanceMethod, [], |
48 {#extra: 1}), | 49 {#extra: 1}), |
49 () => instanceMirror.reflectee.instanceMethod(extra: 1)); | 50 () => instanceMirror.reflectee.instanceMethod(extra: 1)); |
50 expectMatchingErrors(() => instanceMirror.invoke(#instanceMethod, | 51 expectMatchingErrors(() => instanceMirror.invoke(#instanceMethod, |
51 ['positional']), | 52 ['positional']), |
52 () => instanceMirror.reflectee | 53 () => instanceMirror.reflectee |
53 .instanceMethod('positional')); | 54 .instanceMethod('positional')); |
54 } | 55 } |
OLD | NEW |