OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 |
5 closure0() { | 7 closure0() { |
6 var fs = []; | 8 var fs = []; |
7 for (var x = 1; x <= 3; x++) { | 9 for (var x = 1; x <= 3; x++) { |
8 fs.add(fun() { return x; }); | 10 fs.add(fun() { return x; }); |
9 } | 11 } |
10 Expect.equals(3, fs.length); | 12 Expect.equals(3, fs.length); |
11 Expect.equals(1, fs[0]()); | 13 Expect.equals(1, fs[0]()); |
12 Expect.equals(2, fs[1]()); | 14 Expect.equals(2, fs[1]()); |
13 Expect.equals(3, fs[2]()); | 15 Expect.equals(3, fs[2]()); |
14 } | 16 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 Expect.equals(0, g()); | 67 Expect.equals(0, g()); |
66 } | 68 } |
67 | 69 |
68 main() { | 70 main() { |
69 closure0(); | 71 closure0(); |
70 closure1(); | 72 closure1(); |
71 closure2(); | 73 closure2(); |
72 closure3(); | 74 closure3(); |
73 closure4(); | 75 closure4(); |
74 } | 76 } |
OLD | NEW |