OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 for testing bad named parameters. | 4 // Dart test program for testing bad named parameters. |
5 | 5 |
6 import "package:expect/expect.dart"; | |
7 | |
8 class BadNamedParameters2Test { | 6 class BadNamedParameters2Test { |
9 int foo(int a) { | 7 int foo(int a) { |
10 // Although no optional named parameters are declared, we must check that | 8 // Although no optional named parameters are declared, we must check that |
11 // no named arguments are passed in, either here or in the resolving stub. | 9 // no named arguments are passed in, either here or in the resolving stub. |
12 return a; | 10 return a; |
13 } | 11 } |
14 | |
15 static testMain() { | |
16 BadNamedParameters2Test np = new BadNamedParameters2Test(); | |
17 | |
18 // Verify that NoSuchMethod is called after an error is detected. | |
19 bool caught; | |
20 try { | |
21 caught = false; | |
22 // No formal parameter named b. | |
23 np.foo(b:25); // //# 01: static type warning | |
24 } on NoSuchMethodError catch (e) { | |
25 caught = true; | |
26 } | |
27 Expect.equals(true, caught); //# 01: continued | |
28 } | |
29 } | 12 } |
30 | 13 |
31 main() { | 14 main() { |
32 BadNamedParameters2Test.testMain(); | 15 BadNamedParameters2Test np = new BadNamedParameters2Test(); |
| 16 |
| 17 // No formal parameter named b. |
| 18 np.foo(b: 25); //# 01: compile-time error |
33 } | 19 } |
OLD | NEW |