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