OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.invoke_test; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 |
| 9 import 'package:expect/expect.dart'; |
| 10 import "package:async_helper/async_helper.dart"; |
| 11 |
| 12 import 'invoke_private_test.dart' show C; |
| 13 |
| 14 expectThrowsNSM(f) { |
| 15 Expect.throws(f, (e) => e is NoSuchMethodError); |
| 16 } |
| 17 |
| 18 main() { |
| 19 var result; |
| 20 |
| 21 C c = new C(); |
| 22 InstanceMirror im = reflect(c); |
| 23 expectThrowsNSM(() => im.invoke(#_method, [2,4,8])); |
| 24 expectThrowsNSM(() => im.getField(#_getter)); |
| 25 expectThrowsNSM(() => im.getField(#_field)); |
| 26 expectThrowsNSM(() => im.setField(#_setter, 'foo')); |
| 27 expectThrowsNSM(() => im.setField(#_field, 'bar')); |
| 28 |
| 29 ClassMirror cm = reflectClass(C); |
| 30 expectThrowsNSM(() => cm.invoke(#_staticFunction, [3,4])); |
| 31 expectThrowsNSM(() => cm.getField(#_staticGetter)); |
| 32 expectThrowsNSM(() => cm.getField(#_staticField)); |
| 33 expectThrowsNSM(() => cm.setField(#_staticSetter, 'sfoo')); |
| 34 expectThrowsNSM(() => cm.setField(#_staticField, 'sbar')); |
| 35 expectThrowsNSM(() => cm.newInstance(#_named, ['my value'])); |
| 36 |
| 37 LibraryMirror lm = cm.owner; |
| 38 expectThrowsNSM(() => lm.invoke(#_libraryFunction, [':',')'])); |
| 39 expectThrowsNSM(() => lm.getField(#_libraryGetter)); |
| 40 expectThrowsNSM(() => lm.getField(#_libraryField)); |
| 41 expectThrowsNSM(() => lm.setField(#_librarySetter, 'lfoo')); |
| 42 expectThrowsNSM(() => lm.setField(#_libraryField, 'lbar')); |
| 43 } |
OLD | NEW |