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

Side by Side Diff: tests/corelib/iterable_take_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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 main() {
6 List<int> list1 = <int>[1, 2, 3];
7 List<int> list2 = const <int>[4, 5];
8 List<String> list3 = <String>[];
9 Set<int> set1 = new Set<int>();
10 set1..add(11)
11 ..add(12)
12 ..add(13);
13 Set set2 = new Set();
14
15 Iterable<int> take0 = list1.take(0);
16 Iterator<int> it = take0.iterator;
17 Expect.isNull(it.current);
18 Expect.isFalse(it.moveNext());
19 Expect.isNull(it.current);
20
21 Iterable<int> take1 = list1.take(1);
22 it = take1.iterator;
23 Expect.isNull(it.current);
24 Expect.isTrue(it.moveNext());
25 Expect.equals(1, it.current);
26 Expect.isFalse(it.moveNext());
27 Expect.isNull(it.current);
28
29 Iterable<int> take2 = list1.take(2);
30 it = take2.iterator;
31 Expect.isNull(it.current);
32 Expect.isTrue(it.moveNext());
33 Expect.equals(1, it.current);
34 Expect.isTrue(it.moveNext());
35 Expect.equals(2, it.current);
36 Expect.isFalse(it.moveNext());
37 Expect.isNull(it.current);
38
39 Iterable<int> take3 = list1.take(3);
40 it = take3.iterator;
41 Expect.isNull(it.current);
42 Expect.isTrue(it.moveNext());
43 Expect.equals(1, it.current);
44 Expect.isTrue(it.moveNext());
45 Expect.equals(2, it.current);
46 Expect.isTrue(it.moveNext());
47 Expect.equals(3, it.current);
48 Expect.isFalse(it.moveNext());
49 Expect.isNull(it.current);
50
51 Iterable<int> take4 = list1.take(4);
52 it = take4.iterator;
53 Expect.isNull(it.current);
54 Expect.isTrue(it.moveNext());
55 Expect.equals(1, it.current);
56 Expect.isTrue(it.moveNext());
57 Expect.equals(2, it.current);
58 Expect.isTrue(it.moveNext());
59 Expect.equals(3, it.current);
60 Expect.isFalse(it.moveNext());
61 Expect.isNull(it.current);
62
63 take4 = list1.take(4);
64 take3 = take4.take(3);
65 take2 = take3.take(2);
66 take1 = take2.take(1);
67 take0 = take1.take(0);
68 it = take0.iterator;
69 Expect.isNull(it.current);
70 Expect.isFalse(it.moveNext());
71 Expect.isNull(it.current);
72 it = take1.iterator;
73 Expect.isNull(it.current);
74 Expect.isTrue(it.moveNext());
75 Expect.equals(1, it.current);
76 Expect.isFalse(it.moveNext());
77 Expect.isNull(it.current);
78 it = take2.iterator;
79 Expect.isNull(it.current);
80 Expect.isTrue(it.moveNext());
81 Expect.equals(1, it.current);
82 Expect.isTrue(it.moveNext());
83 Expect.equals(2, it.current);
84 Expect.isFalse(it.moveNext());
85 Expect.isNull(it.current);
86 it = take3.iterator;
87 Expect.isNull(it.current);
88 Expect.isTrue(it.moveNext());
89 Expect.equals(1, it.current);
90 Expect.isTrue(it.moveNext());
91 Expect.equals(2, it.current);
92 Expect.isTrue(it.moveNext());
93 Expect.equals(3, it.current);
94 Expect.isFalse(it.moveNext());
95 Expect.isNull(it.current);
96 it = take4.iterator;
97 Expect.isNull(it.current);
98 Expect.isTrue(it.moveNext());
99 Expect.equals(1, it.current);
100 Expect.isTrue(it.moveNext());
101 Expect.equals(2, it.current);
102 Expect.isTrue(it.moveNext());
103 Expect.equals(3, it.current);
104 Expect.isFalse(it.moveNext());
105 Expect.isNull(it.current);
106
107 take0 = list2.take(0);
108 it = take0.iterator;
109 Expect.isNull(it.current);
110 Expect.isFalse(it.moveNext());
111 Expect.isNull(it.current);
112
113 take1 = list2.take(1);
114 it = take1.iterator;
115 Expect.isNull(it.current);
116 Expect.isTrue(it.moveNext());
117 Expect.equals(4, it.current);
118 Expect.isFalse(it.moveNext());
119 Expect.isNull(it.current);
120
121 take2 = list2.take(2);
122 it = take2.iterator;
123 Expect.isNull(it.current);
124 Expect.isTrue(it.moveNext());
125 Expect.equals(4, it.current);
126 Expect.isTrue(it.moveNext());
127 Expect.equals(5, it.current);
128 Expect.isFalse(it.moveNext());
129 Expect.isNull(it.current);
130
131 take3 = list2.take(3);
132 it = take3.iterator;
133 Expect.isNull(it.current);
134 Expect.isTrue(it.moveNext());
135 Expect.equals(4, it.current);
136 Expect.isTrue(it.moveNext());
137 Expect.equals(5, it.current);
138 Expect.isFalse(it.moveNext());
139 Expect.isNull(it.current);
140
141 Iterable<String> take02 = list3.take(0);
142 Iterator<String> it2 = take02.iterator;
143 Expect.isNull(it2.current);
144 Expect.isFalse(it2.moveNext());
145 Expect.isNull(it2.current);
146
147 Iterable<String> take12 = list3.take(1);
148 it2 = take12.iterator;
149 Expect.isNull(it2.current);
150 Expect.isFalse(it2.moveNext());
151 Expect.isNull(it2.current);
152
153 take0 = set1.take(0);
154 it = take0.iterator;
155 Expect.isNull(it.current);
156 Expect.isFalse(it.moveNext());
157 Expect.isNull(it.current);
158
159 take1 = set1.take(1);
160 List<int> copied = take1.toList();
161 Expect.equals(1, copied.length);
162 Expect.isTrue(set1.contains(copied[0]));
163 it = take1.iterator;
164 Expect.isNull(it.current);
165 Expect.isTrue(it.moveNext());
166 Expect.isNotNull(it.current);
167 Expect.isFalse(it.moveNext());
168 Expect.isNull(it.current);
169
170 take2 = set1.take(2);
171 copied = take2.toList();
172 Expect.equals(2, copied.length);
173 Expect.isTrue(set1.contains(copied[0]));
174 Expect.isTrue(set1.contains(copied[1]));
175 Expect.isTrue(copied[0] != copied[1]);
176 it = take2.iterator;
177 Expect.isNull(it.current);
178 Expect.isTrue(it.moveNext());
179 Expect.isNotNull(it.current);
180 Expect.isTrue(it.moveNext());
181 Expect.isNotNull(it.current);
182 Expect.isFalse(it.moveNext());
183 Expect.isNull(it.current);
184
185 take3 = set1.take(3);
186 copied = take3.toList();
187 Expect.equals(3, copied.length);
188 Expect.isTrue(set1.contains(copied[0]));
189 Expect.isTrue(set1.contains(copied[1]));
190 Expect.isTrue(set1.contains(copied[2]));
191 Expect.isTrue(copied[0] != copied[1]);
192 Expect.isTrue(copied[0] != copied[2]);
193 Expect.isTrue(copied[1] != copied[2]);
194 it = take3.iterator;
195 Expect.isNull(it.current);
196 Expect.isTrue(it.moveNext());
197 Expect.isNotNull(it.current);
198 Expect.isTrue(it.moveNext());
199 Expect.isNotNull(it.current);
200 Expect.isTrue(it.moveNext());
201 Expect.isNotNull(it.current);
202 Expect.isFalse(it.moveNext());
203 Expect.isNull(it.current);
204
205 take0 = set2.take(0);
206 it = take0.iterator;
207 Expect.isNull(it.current);
208 Expect.isFalse(it.moveNext());
209 Expect.isNull(it.current);
210
211 take1 = set2.take(1);
212 it = take1.iterator;
213 Expect.isNull(it.current);
214 Expect.isFalse(it.moveNext());
215 Expect.isNull(it.current);
216 }
OLDNEW
« no previous file with comments | « tests/corelib/iterable_skip_while_test.dart ('k') | tests/corelib/iterable_take_while_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698