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 // Test to check that we can parse closure type formal parameters with | 4 // Test to check that we can parse closure type formal parameters with |
5 // default value. | 5 // default value. |
6 | 6 |
7 import "package:expect/expect.dart"; | |
8 | |
9 class FunctionTypeParameterTest { | 7 class FunctionTypeParameterTest { |
10 | 8 |
11 static var formatter; | 9 static var formatter; |
12 | 10 |
13 static SetFormatter([String fmt(int i) = null]) { | 11 static SetFormatter([String fmt(int i) = null]) { |
14 formatter = fmt; | 12 formatter = fmt; |
15 } | 13 } |
16 | 14 |
17 static void testMain() { | 15 static void testMain() { |
18 Expect.equals(null, formatter); | 16 Expect.equals(null, formatter); |
19 SetFormatter((i) => "$i"); | 17 SetFormatter((i) => "$i"); |
20 Expect.equals(false, null == formatter); | 18 Expect.equals(false, null == formatter); |
21 Expect.equals("1234", formatter(1230 + 4)); | 19 Expect.equals("1234", formatter(1230 + 4)); |
22 SetFormatter(); | 20 SetFormatter(); |
23 Expect.equals(null, formatter); | 21 Expect.equals(null, formatter); |
24 } | 22 } |
25 } | 23 } |
26 | 24 |
27 main() { | 25 main() { |
28 FunctionTypeParameterTest.testMain(); | 26 FunctionTypeParameterTest.testMain(); |
29 } | 27 } |
OLD | NEW |