OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart test program testing that NoSuchMethod is properly called. | 4 // Dart test program testing that NoSuchMethod is properly called. |
5 | 5 |
6 import "package:expect/expect.dart"; | |
7 | |
8 class NoSuchMethodTest { | 6 class NoSuchMethodTest { |
9 | 7 |
10 foo({a : 10, b : 20}) { | 8 foo({a : 10, b : 20}) { |
11 return (10 * a) + b; | 9 return (10 * a) + b; |
12 } | 10 } |
13 | 11 |
14 noSuchMethod(InvocationMirror im) { | 12 noSuchMethod(InvocationMirror im) { |
15 Expect.equals("moo", im.memberName); | 13 Expect.equals("moo", im.memberName); |
16 Expect.equals(0, im.positionalArguments.length); | 14 Expect.equals(0, im.positionalArguments.length); |
17 Expect.equals(1, im.namedArguments.length); | 15 Expect.equals(1, im.namedArguments.length); |
18 return foo(b:im.namedArguments["b"]); | 16 return foo(b:im.namedArguments["b"]); |
19 } | 17 } |
20 | 18 |
21 static testMain() { | 19 static testMain() { |
22 var obj = new NoSuchMethodTest(); | 20 var obj = new NoSuchMethodTest(); |
23 Expect.equals(199, obj.moo(b:99)); // obj.NoSuchMethod called here. | 21 Expect.equals(199, obj.moo(b:99)); // obj.NoSuchMethod called here. |
24 } | 22 } |
25 } | 23 } |
26 | 24 |
27 main() { | 25 main() { |
28 NoSuchMethodTest.testMain(); | 26 NoSuchMethodTest.testMain(); |
29 } | 27 } |
OLD | NEW |