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 | |
7 closure0() { | 5 closure0() { |
8 var input = [1, 2, 3]; | 6 var input = [1, 2, 3]; |
9 var fs = []; | 7 var fs = []; |
10 for (var x in input) { | 8 for (var x in input) { |
11 fs.add(fun() { return x; }); | 9 fs.add(fun() { return x; }); |
12 } | 10 } |
13 Expect.equals(3, fs.length); | 11 Expect.equals(3, fs.length); |
14 Expect.equals(1, fs[0]()); | 12 Expect.equals(1, fs[0]()); |
15 Expect.equals(2, fs[1]()); | 13 Expect.equals(2, fs[1]()); |
16 Expect.equals(3, fs[2]()); | 14 Expect.equals(3, fs[2]()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 84 } |
87 | 85 |
88 main() { | 86 main() { |
89 closure0(); | 87 closure0(); |
90 closure1(); | 88 closure1(); |
91 closure2(); | 89 closure2(); |
92 closure3(); | 90 closure3(); |
93 closure4(); | 91 closure4(); |
94 closure5(); | 92 closure5(); |
95 } | 93 } |
OLD | NEW |