OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // Dart test for testing for in on a list literal. | |
6 | |
7 class ForInTest { | |
8 | |
9 static testMain() { | |
10 testSimple(); | |
11 testGenericSyntax1(); | |
12 testGenericSyntax2(); | |
13 testGenericSyntax3(); | |
14 testGenericSyntax4(); | |
15 } | |
16 | |
17 static void testSimple() { | |
18 var list = [1, 3, 5]; | |
19 var sum = 0; | |
20 for (var i in list) { | |
21 sum += i; | |
22 } | |
23 Expect.equals(9, sum); | |
24 } | |
25 | |
26 static void testGenericSyntax1() { | |
27 List<List<String>> aCollection = []; | |
28 for (List<String> strArrArr in aCollection) {} | |
29 } | |
30 | |
31 static void testGenericSyntax2() { | |
32 List<List<String>> aCollection = []; | |
33 List<String> strArrArr; | |
34 for (strArrArr in aCollection) {} | |
35 } | |
36 | |
37 static void testGenericSyntax3() { | |
38 List<List<List<String>>> aCollection = []; | |
39 for (List<List<String>> strArrArr in aCollection) {} | |
40 } | |
41 | |
42 static void testGenericSyntax4() { | |
43 List<List<List<String>>> aCollection = []; | |
44 List<List<String>> strArrArr; | |
45 for (strArrArr in aCollection) {} | |
46 } | |
47 | |
48 } | |
49 | |
50 main() { | |
51 ForInTest.testMain(); | |
52 } | |
OLD | NEW |