OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 // Dart test program testing that NoSuchMethod is properly called. |
| 5 |
| 6 import "package:expect/expect.dart"; |
| 7 |
| 8 Invocation invocation; |
| 9 |
| 10 class C { |
| 11 noSuchMethod(Invocation i) { |
| 12 invocation = i; |
| 13 return 42; |
| 14 } |
| 15 } |
| 16 |
| 17 expectNSME(Object d) { |
| 18 try { |
| 19 d.noSuchMethod(invocation); |
| 20 } on NoSuchMethodError catch (e) { |
| 21 Expect.isTrue(e.toString().contains('foobar')); |
| 22 } |
| 23 } |
| 24 |
| 25 main() { |
| 26 dynamic c = new C(); |
| 27 Expect.equals(42, c.foobar(123)); |
| 28 Expect.equals(invocation.memberName, #foobar); |
| 29 Expect.listEquals(invocation.positionalArguments, [123]); |
| 30 expectNSME(null); |
| 31 expectNSME(777); |
| 32 expectNSME('hello'); |
| 33 // These fail because of https://github.com/dart-lang/dev_compiler/issues/592. |
| 34 // expectNSME([]); |
| 35 // expectNSME(['a', 'b', 'c']); |
| 36 } |
OLD | NEW |