OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.mirrors_nsm_mistatch; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 import 'mirrors_nsm_test.dart'; |
| 9 |
| 10 topLevelMethod({missing}) {} |
| 11 class C { |
| 12 C.constructor({missing}); |
| 13 factory C.redirecting({missing}) = C.constructor; |
| 14 static staticMethod({missing}) {} |
| 15 instanceMethod({missing}) {} |
| 16 } |
| 17 |
| 18 main() { |
| 19 var mirrors = currentMirrorSystem(); |
| 20 var libMirror = mirrors.findLibrary(#test.mirrors_nsm_mistatch); |
| 21 expectMatchingErrors(() => libMirror.invoke(#topLevelMethod, [], {#extra: 1}), |
| 22 () => topLevelMethod(extra: 1)); |
| 23 expectMatchingErrors(() => libMirror.invoke(#topLevelMethod, ['positional']), |
| 24 () => topLevelMethod('positional')); |
| 25 |
| 26 var classMirror = reflectClass(C); |
| 27 expectMatchingErrors(() => classMirror.newInstance(#constructor, [], |
| 28 {#extra: 1}), |
| 29 () => new C.constructor(extra: 1)); |
| 30 expectMatchingErrors(() => classMirror.newInstance(#redirecting, [], |
| 31 {#extra: 1}), |
| 32 () => new C.redirecting(extra: 1)); |
| 33 expectMatchingErrors(() => classMirror.invoke(#staticMethod, [], |
| 34 {#extra: 1}), |
| 35 () => C.staticMethod(extra: 1)); |
| 36 expectMatchingErrors(() => classMirror.newInstance(#constructor, |
| 37 ['positional']), |
| 38 () => new C.constructor('positional')); |
| 39 expectMatchingErrors(() => classMirror.newInstance(#redirecting, |
| 40 ['positional']), |
| 41 () => new C.redirecting('positional')); |
| 42 expectMatchingErrors(() => classMirror.invoke(#staticMethod, |
| 43 ['positional']), |
| 44 () => C.staticMethod('positional')); |
| 45 |
| 46 var instanceMirror = reflect(new C.constructor()); |
| 47 expectMatchingErrors(() => instanceMirror.invoke(#instanceMethod, [], |
| 48 {#extra: 1}), |
| 49 () => instanceMirror.reflectee.instanceMethod(extra: 1)); |
| 50 expectMatchingErrors(() => instanceMirror.invoke(#instanceMethod, |
| 51 ['positional']), |
| 52 () => instanceMirror.reflectee |
| 53 .instanceMethod('positional')); |
| 54 } |
OLD | NEW |