OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 // Tests of for-in loops and list literals. | |
6 | |
7 import 'expect.dart'; | |
8 | |
9 fact4() { | |
10 var f = 1; | |
11 for (var n in [1, 2, 3, 4]) { | |
12 f *= n; | |
13 } | |
14 return f; | |
15 } | |
16 | |
17 fact5() { | |
18 var f = 1, n; | |
19 for (n in [1, 2, 3, 4, 5]) { | |
20 f *= n; | |
21 } | |
22 return f; | |
23 } | |
24 | |
25 var global; | |
26 fact6() { | |
27 var f = 1; | |
28 for (global in [1, 2, 3, 4, 5, 6]) { | |
29 f *= global; | |
30 } | |
31 return f; | |
32 } | |
33 | |
34 main() { | |
35 Expect.isTrue(fact4() == 24); | |
36 Expect.isTrue(fact5() == 120); | |
37 Expect.isTrue(fact6() == 720); | |
38 } | |
OLD | NEW |