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