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

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

Issue 11412086: Make 'where' lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: FilteredIterable/Iterator -> WhereIterable/Iterator. Created 8 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
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 queue_test; 5 library queue_test;
6 6
7 class QueueTest { 7 class QueueTest {
8 8
9 static testMain() { 9 static testMain() {
10 Queue queue = new Queue(); 10 Queue queue = new Queue();
(...skipping 30 matching lines...) Expand all
41 return (value == 10); 41 return (value == 10);
42 } 42 }
43 43
44 Queue mapped = new Queue.from(queue.mappedBy(mapTest)); 44 Queue mapped = new Queue.from(queue.mappedBy(mapTest));
45 checkQueue(mapped, 3, 111); 45 checkQueue(mapped, 3, 111);
46 checkQueue(queue, 3, 1110); 46 checkQueue(queue, 3, 1110);
47 Expect.equals(1, mapped.removeFirst()); 47 Expect.equals(1, mapped.removeFirst());
48 Expect.equals(100, mapped.removeLast()); 48 Expect.equals(100, mapped.removeLast());
49 Expect.equals(10, mapped.removeFirst()); 49 Expect.equals(10, mapped.removeFirst());
50 50
51 Queue other = queue.where(is10); 51 Queue other = new Queue.from(queue.where(is10));
52 checkQueue(other, 1, 10); 52 checkQueue(other, 1, 10);
53 53
54 Expect.equals(true, queue.some(is10)); 54 Expect.equals(true, queue.some(is10));
55 55
56 bool isInstanceOfInt(int value) { 56 bool isInstanceOfInt(int value) {
57 return (value is int); 57 return (value is int);
58 } 58 }
59 59
60 Expect.equals(true, queue.every(isInstanceOfInt)); 60 Expect.equals(true, queue.every(isInstanceOfInt));
61 61
(...skipping 29 matching lines...) Expand all
91 queue.addFirst(2); 91 queue.addFirst(2);
92 Expect.equals(2, queue.first); 92 Expect.equals(2, queue.first);
93 Expect.equals(1, queue.last); 93 Expect.equals(1, queue.last);
94 94
95 queue.addLast(3); 95 queue.addLast(3);
96 Expect.equals(3, queue.last); 96 Expect.equals(3, queue.last);
97 bool isGreaterThanOne(int value) { 97 bool isGreaterThanOne(int value) {
98 return (value > 1); 98 return (value > 1);
99 } 99 }
100 100
101 other = queue.where(isGreaterThanOne); 101 other = new Queue.from(queue.where(isGreaterThanOne));
102 checkQueue(other, 2, 5); 102 checkQueue(other, 2, 5);
103 103
104 testAddAll(); 104 testAddAll();
105 } 105 }
106 106
107 static void checkQueue(Queue queue, int expectedSize, int expectedSum) { 107 static void checkQueue(Queue queue, int expectedSize, int expectedSum) {
108 Expect.equals(expectedSize, queue.length); 108 Expect.equals(expectedSize, queue.length);
109 int sum = 0; 109 int sum = 0;
110 void sumElements(int value) { 110 void sumElements(int value) {
111 sum += value; 111 sum += value;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 entry1 = entry1.nextEntry(); 177 entry1 = entry1.nextEntry();
178 entry2 = entry2.nextEntry(); 178 entry2 = entry2.nextEntry();
179 } 179 }
180 Expect.equals(null, entry2); 180 Expect.equals(null, entry2);
181 } 181 }
182 } 182 }
183 183
184 main() { 184 main() {
185 QueueTest.testMain(); 185 QueueTest.testMain();
186 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698