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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Test to check that we can parse closure type formal parameters with | 7 // Test to check that we can parse closure type formal parameters with |
8 // default value. | 8 // default value. |
9 | 9 |
10 class A { | 10 class A { |
11 final f; | 11 final f; |
12 A(int this.f()); | 12 A(int this.f()); |
13 const A.nother(int this.f()); | 13 const A.nother(int this.f()); |
14 | 14 |
15 static Function func; | 15 static Function func; |
16 | 16 |
17 static SetFunc([String fmt(int i) = null]) { | 17 static SetFunc([String fmt(int i) = null]) { |
18 func = fmt; | 18 func = fmt; |
19 } | 19 } |
20 | |
21 } | 20 } |
22 | 21 |
23 main() { | 22 main() { |
24 Expect.equals(null, A.func); | 23 Expect.equals(null, A.func); |
25 A.SetFunc((i) => "$i"); | 24 A.SetFunc((i) => "$i"); |
26 Expect.equals(false, null == A.func); | 25 Expect.equals(false, null == A.func); |
27 Expect.equals("1234", A.func(1230 + 4)); | 26 Expect.equals("1234", A.func(1230 + 4)); |
28 A.SetFunc(); | 27 A.SetFunc(); |
29 Expect.equals(null, A.func); | 28 Expect.equals(null, A.func); |
30 | 29 |
31 Expect.equals(42, new A(() => 42).f()); | 30 Expect.equals(42, new A(() => 42).f()); |
32 Expect.equals(42, new A.nother(() => 42).f()); | 31 Expect.equals(42, new A.nother(() => 42).f()); |
33 } | 32 } |
OLD | NEW |