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

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

Issue 55533002: Fix some corelib tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor updates Created 7 years, 1 month 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/iterable_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) 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"; 5 import "package:expect/expect.dart";
6 6
7 main() { 7 main() {
8 testOperations(); 8 testOperations();
9 } 9 }
10 10
11 class ThrowMarker { 11 class ThrowMarker {
12 const ThrowMarker(); 12 const ThrowMarker();
13 String toString() => "<<THROWS>>"; 13 String toString() => "<<THROWS>>";
14 } 14 }
15 15
16 void testOperations() { 16 void testOperations() {
17 // Comparison lists. 17 // Comparison lists.
18 List l = const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 18 List l = const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
19 List r = const [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]; 19 List r = const [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
20 // Function that reverses l and r lists when used to map. 20 // Function that reverses l and r lists when used to map.
21 int rev(x) => 11 - x; 21 int rev(x) => 11 - x;
22 // A base list that starts out like l, but isn't const. 22 // A base list that starts out like l, but isn't const.
23 Iterable base = l.map((x) => x).toList(); 23 List base = l.map((x) => x).toList();
24 24
25 Iterable reversed = l.map(rev); 25 Iterable reversed = l.map(rev);
26 26
27 Expect.listEquals(r, l.map(rev).toList()); 27 Expect.listEquals(r, l.map(rev).toList());
28 Expect.listEquals(l, l.map(rev).map(rev).toList()); 28 Expect.listEquals(l, l.map(rev).map(rev).toList());
29 for (int i = 0; i < r.length; i++) { 29 for (int i = 0; i < r.length; i++) {
30 Expect.equals(r[i], reversed.elementAt(i)); 30 Expect.equals(r[i], reversed.elementAt(i));
31 } 31 }
32 Expect.equals(4, base.indexOf(5)); 32 Expect.equals(4, base.indexOf(5));
33 Expect.equals(5, reversed.toList().indexOf(5)); 33 Expect.equals(5, reversed.toList().indexOf(5));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 testList([0, 1, 2, 3]); 155 testList([0, 1, 2, 3]);
156 testList([3, 4, 5, 6]); 156 testList([3, 4, 5, 6]);
157 testList([10, 11, 12, 13]); 157 testList([10, 11, 12, 13]);
158 testList(l); 158 testList(l);
159 testList(r); 159 testList(r);
160 testList(base); 160 testList(base);
161 161
162 // Reverse const list. 162 // Reverse const list.
163 Expect.listEquals(r, l.map(rev).toList()); 163 Expect.listEquals(r, l.map(rev).toList());
164 } 164 }
OLDNEW
« no previous file with comments | « tests/corelib/iterable_test.dart ('k') | tests/corelib/map_keys2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698