Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: tests/corelib/list_test.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/corelib/list_set_range_test.dart ('k') | tests/corelib/map_keys2_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 class ListTest { 5 class ListTest {
6 6
7 static testMain() { 7 static testMain() {
8 testList(); 8 testList();
9 testExpandableList(); 9 testExpandableList();
10 } 10 }
11 11
12 static void expectValues(list, val1, val2, val3, val4) { 12 static void expectValues(list, val1, val2, val3, val4) {
13 Expect.equals(true, list.length == 4); 13 Expect.equals(true, list.length == 4);
14 Expect.equals(true, list.length == 4); 14 Expect.equals(true, list.length == 4);
15 Expect.equals(true, !list.isEmpty); 15 Expect.equals(true, !list.isEmpty);
16 Expect.equals(list[0], val1); 16 Expect.equals(list[0], val1);
17 Expect.equals(list[1], val2); 17 Expect.equals(list[1], val2);
18 Expect.equals(list[2], val3); 18 Expect.equals(list[2], val3);
19 Expect.equals(list[3], val4); 19 Expect.equals(list[3], val4);
20 } 20 }
21 21
22 static void testClosures(List list) { 22 static void testClosures(List list) {
23 testMap(val) {return val * 2 + 10; } 23 testMap(val) {return val * 2 + 10; }
24 Collection mapped = list.map(testMap); 24 List mapped = list.mappedBy(testMap).toList();
25 Expect.equals(mapped.length, list.length); 25 Expect.equals(mapped.length, list.length);
26 for (var i = 0; i < list.length; i++) { 26 for (var i = 0; i < list.length; i++) {
27 Expect.equals(mapped[i], list[i]*2 + 10); 27 Expect.equals(mapped[i], list[i]*2 + 10);
28 } 28 }
29 29
30 testFilter(val) { return val == 3; } 30 testFilter(val) { return val == 3; }
31 Collection filtered = list.filter(testFilter); 31 Iterable filtered = list.where(testFilter);
32 Expect.equals(filtered.length, 1); 32 Expect.equals(filtered.length, 1);
33 33
34 testEvery(val) { return val != 11; } 34 testEvery(val) { return val != 11; }
35 bool test = list.every(testEvery); 35 bool test = list.every(testEvery);
36 Expect.equals(true, test); 36 Expect.equals(true, test);
37 37
38 testSome(val) { return val == 1; } 38 testSome(val) { return val == 1; }
39 test = list.some(testSome); 39 test = list.any(testSome);
40 Expect.equals(true, test); 40 Expect.equals(true, test);
41 41
42 testSomeFirst(val) { return val == 0; } 42 testSomeFirst(val) { return val == 0; }
43 test = list.some(testSomeFirst); 43 test = list.any(testSomeFirst);
44 Expect.equals(true, test); 44 Expect.equals(true, test);
45 45
46 testSomeLast(val) { return val == (list.length - 1); } 46 testSomeLast(val) { return val == (list.length - 1); }
47 test = list.some(testSomeLast); 47 test = list.any(testSomeLast);
48 Expect.equals(true, test); 48 Expect.equals(true, test);
49 } 49 }
50 50
51 static void testList() { 51 static void testList() {
52 List list = new List(4); 52 List list = new List.fixedLength(4);
53 Expect.equals(list.length, 4); 53 Expect.equals(list.length, 4);
54 list[0] = 4; 54 list[0] = 4;
55 expectValues(list, 4, null, null, null); 55 expectValues(list, 4, null, null, null);
56 String val = "fisk"; 56 String val = "fisk";
57 list[1] = val; 57 list[1] = val;
58 expectValues(list, 4, val, null, null); 58 expectValues(list, 4, val, null, null);
59 double d = 2.0; 59 double d = 2.0;
60 list[3] = d; 60 list[3] = d;
61 expectValues(list, 4, val, null, d); 61 expectValues(list, 4, val, null, d);
62 62
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 } 144 }
145 145
146 class Yes { 146 class Yes {
147 operator ==(var other) => true; 147 operator ==(var other) => true;
148 } 148 }
149 149
150 main() { 150 main() {
151 ListTest.testMain(); 151 ListTest.testMain();
152 } 152 }
OLDNEW
« no previous file with comments | « tests/corelib/list_set_range_test.dart ('k') | tests/corelib/map_keys2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698