OLD | NEW |
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 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 class QueueTest { | 9 class QueueTest { |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 checkQueue(queue, 3, 1110); | 36 checkQueue(queue, 3, 1110); |
37 | 37 |
38 int mapTest(int value) { | 38 int mapTest(int value) { |
39 return value ~/ 10; | 39 return value ~/ 10; |
40 } | 40 } |
41 | 41 |
42 bool is10(int value) { | 42 bool is10(int value) { |
43 return (value == 10); | 43 return (value == 10); |
44 } | 44 } |
45 | 45 |
46 Queue mapped = new Queue.from(queue.mappedBy(mapTest)); | 46 Queue mapped = new Queue.from(queue.map(mapTest)); |
47 checkQueue(mapped, 3, 111); | 47 checkQueue(mapped, 3, 111); |
48 checkQueue(queue, 3, 1110); | 48 checkQueue(queue, 3, 1110); |
49 Expect.equals(1, mapped.removeFirst()); | 49 Expect.equals(1, mapped.removeFirst()); |
50 Expect.equals(100, mapped.removeLast()); | 50 Expect.equals(100, mapped.removeLast()); |
51 Expect.equals(10, mapped.removeFirst()); | 51 Expect.equals(10, mapped.removeFirst()); |
52 | 52 |
53 Queue other = new Queue.from(queue.where(is10)); | 53 Queue other = new Queue.from(queue.where(is10)); |
54 checkQueue(other, 1, 10); | 54 checkQueue(other, 1, 10); |
55 | 55 |
56 Expect.equals(true, queue.any(is10)); | 56 Expect.equals(true, queue.any(is10)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 entry1 = entry1.nextEntry(); | 179 entry1 = entry1.nextEntry(); |
180 entry2 = entry2.nextEntry(); | 180 entry2 = entry2.nextEntry(); |
181 } | 181 } |
182 Expect.equals(null, entry2); | 182 Expect.equals(null, entry2); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 main() { | 186 main() { |
187 QueueTest.testMain(); | 187 QueueTest.testMain(); |
188 } | 188 } |
OLD | NEW |