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

Side by Side Diff: tests/corelib/src/QueueTest.dart

Issue 9114021: Added method map to Collection interface and all its implementations (except classes generated fr... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
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 #library("QueueTest.dart"); 5 #library("QueueTest.dart");
6 #import("dart:coreimpl"); 6 #import("dart:coreimpl");
7 7
8 class QueueTest { 8 class QueueTest {
9 9
10 static testMain() { 10 static testMain() {
(...skipping 16 matching lines...) Expand all
27 queue.addFirst(1); 27 queue.addFirst(1);
28 queue.addLast(100); 28 queue.addLast(100);
29 queue.addLast(1000); 29 queue.addLast(1000);
30 Expect.equals(1000, queue.removeLast()); 30 Expect.equals(1000, queue.removeLast());
31 queue.addLast(1000); 31 queue.addLast(1000);
32 checkQueue(queue, 4, 1111); 32 checkQueue(queue, 4, 1111);
33 33
34 queue.removeFirst(); 34 queue.removeFirst();
35 checkQueue(queue, 3, 1110); 35 checkQueue(queue, 3, 1110);
36 36
37 bool is10(int value) { 37 int mapTest(int value) {
38 return value~/10;
ahe 2012/01/05 22:36:54 Spaces around operator.
39 }
40
41 bool is10(int value) {
ahe 2012/01/05 22:36:54 Remove trailing whitespace.
38 return (value == 10); 42 return (value == 10);
39 } 43 }
40 44
45 Queue mapped = queue.map(mapTest);
46 checkQueue(mapped, 3, 111);
47 checkQueue(queue, 3, 1110);
48 Expect.equals(1, mapped.removeFirst());
49 Expect.equals(100, mapped.removeLast());
50 Expect.equals(10, mapped.removeFirst());
51
41 Queue other = queue.filter(is10); 52 Queue other = queue.filter(is10);
42 checkQueue(other, 1, 10); 53 checkQueue(other, 1, 10);
43 54
44 Expect.equals(true, queue.some(is10)); 55 Expect.equals(true, queue.some(is10));
45 56
46 bool isInstanceOfInt(int value) { 57 bool isInstanceOfInt(int value) {
47 return (value is int); 58 return (value is int);
48 } 59 }
49 60
50 Expect.equals(true, queue.every(isInstanceOfInt)); 61 Expect.equals(true, queue.every(isInstanceOfInt));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 159
149 Expect.equals(0, set.length); 160 Expect.equals(0, set.length);
150 Expect.equals(0, queue1.length); 161 Expect.equals(0, queue1.length);
151 Expect.equals(0, queue2.length); 162 Expect.equals(0, queue2.length);
152 Expect.equals(0, queue3.length); 163 Expect.equals(0, queue3.length);
153 164
154 testQueueElements(); 165 testQueueElements();
155 } 166 }
156 167
157 static testQueueElements() { 168 static testQueueElements() {
158 Queue<int> queue1 = new DoubleLinkedQueue<int>.from([1, 2, 4]); 169 DoubleLinkedQueue<int> queue1 = new DoubleLinkedQueue<int>.from([1, 2, 4]);
159 Queue<int> queue2 = new DoubleLinkedQueue<int>(); 170 DoubleLinkedQueue<int> queue2 = new DoubleLinkedQueue<int>();
160 queue2.addAll(queue1); 171 queue2.addAll(queue1);
161 172
162 Expect.equals(queue1.length, queue2.length); 173 Expect.equals(queue1.length, queue2.length);
163 DoubleLinkedQueueEntry<int> entry1 = queue1.firstEntry(); 174 DoubleLinkedQueueEntry<int> entry1 = queue1.firstEntry();
164 DoubleLinkedQueueEntry<int> entry2 = queue2.firstEntry(); 175 DoubleLinkedQueueEntry<int> entry2 = queue2.firstEntry();
165 while (entry1 != null) { 176 while (entry1 != null) {
166 Expect.equals(true, entry1 !== entry2); 177 Expect.equals(true, entry1 !== entry2);
167 entry1 = entry1.nextEntry(); 178 entry1 = entry1.nextEntry();
168 entry2 = entry2.nextEntry(); 179 entry2 = entry2.nextEntry();
169 } 180 }
170 Expect.equals(null, entry2); 181 Expect.equals(null, entry2);
171 } 182 }
172 } 183 }
173 184
174 main() { 185 main() {
175 QueueTest.testMain(); 186 QueueTest.testMain();
176 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698