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