| 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 // Dart test program testing closures. | 4 // Dart test program testing closures. |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | |
| 7 | |
| 8 class LocalFunctionTest { | 6 class LocalFunctionTest { |
| 9 LocalFunctionTest() : field1 = 100, field2_ = 200 { } | 7 LocalFunctionTest() : field1 = 100, field2_ = 200 { } |
| 10 static int f(int n) { | 8 static int f(int n) { |
| 11 int a = 0; | 9 int a = 0; |
| 12 g(int m) { | 10 g(int m) { |
| 13 a = 3*n + m + 1; // Capture parameter n and local a. | 11 a = 3*n + m + 1; // Capture parameter n and local a. |
| 14 return a; | 12 return a; |
| 15 } | 13 } |
| 16 var b = g(n); | 14 var b = g(n); |
| 17 return a + b; | 15 return a + b; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 Expect.equals(24*25/2, testNesting(5)); | 183 Expect.equals(24*25/2, testNesting(5)); |
| 186 Expect.equals(true, testClosureCallStatement(7)); | 184 Expect.equals(true, testClosureCallStatement(7)); |
| 187 Expect.equals(99, doThis(10, (n) => n * n - 1)); | 185 Expect.equals(99, doThis(10, (n) => n * n - 1)); |
| 188 testExceptions(); | 186 testExceptions(); |
| 189 } | 187 } |
| 190 } | 188 } |
| 191 | 189 |
| 192 main() { | 190 main() { |
| 193 LocalFunctionTest.testMain(); | 191 LocalFunctionTest.testMain(); |
| 194 } | 192 } |
| OLD | NEW |