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 // Dart test for new function type alias. | 5 // Dart test for new function type alias. |
6 | 6 |
7 import "package:expect/expect.dart"; | |
8 | |
9 class FunctionLiteralsTest { | 7 class FunctionLiteralsTest { |
10 | 8 |
11 static void testMain() { | 9 static void testMain() { |
12 f(x) { return x * 2;} | 10 f(x) { return x * 2;} |
13 f(42); // make sure it is parsed as a function call | 11 f(42); // make sure it is parsed as a function call |
14 Expect.equals(20, f(10)); | 12 Expect.equals(20, f(10)); |
15 | 13 |
16 int g(x) { return x * 2;} | 14 int g(x) { return x * 2;} |
17 g(42); // make sure it is parsed as a function call | 15 g(42); // make sure it is parsed as a function call |
18 Expect.equals(20, g(10)); | 16 Expect.equals(20, g(10)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 class B { | 67 class B { |
70 var f; | 68 var f; |
71 int n; | 69 int n; |
72 B(z) : f = ((x) => x * x) { n = z; } | 70 B(z) : f = ((x) => x * x) { n = z; } |
73 B.withZ(z) : f = ((x) { return x * x + 1; }) { n = z; } | 71 B.withZ(z) : f = ((x) { return x * x + 1; }) { n = z; } |
74 } | 72 } |
75 | 73 |
76 main() { | 74 main() { |
77 FunctionLiteralsTest.testMain(); | 75 FunctionLiteralsTest.testMain(); |
78 } | 76 } |
OLD | NEW |