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

Side by Side Diff: pkg/async/test/stream_zip_test.dart

Issue 217113002: pkg/async: updates for unittest deprecations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
« no previous file with comments | « pkg/async/pubspec.yaml ('k') | pkg/async/test/stream_zip_zone_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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "dart:async"; 5 import "dart:async";
6 import "package:async/stream_zip.dart"; 6 import "package:async/stream_zip.dart";
7 import "package:unittest/unittest.dart"; 7 import "package:unittest/unittest.dart";
8 8
9 /// Create an error with the same values as [base], except that it throwsA 9 /// Create an error with the same values as [base], except that it throwsA
10 /// when seeing the value [errorValue]. 10 /// when seeing the value [errorValue].
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 /// Counter used to give varying delays for streams. 33 /// Counter used to give varying delays for streams.
34 int ctr = 0; 34 int ctr = 0;
35 35
36 main() { 36 main() {
37 // Test that zipping [streams] gives the results iterated by [expectedData]. 37 // Test that zipping [streams] gives the results iterated by [expectedData].
38 testZip(Iterable streams, Iterable expectedData) { 38 testZip(Iterable streams, Iterable expectedData) {
39 List data = []; 39 List data = [];
40 Stream zip = new StreamZip(streams); 40 Stream zip = new StreamZip(streams);
41 zip.listen(data.add, onDone: expectAsync0(() { 41 zip.listen(data.add, onDone: expectAsync(() {
42 expect(data, equals(expectedData)); 42 expect(data, equals(expectedData));
43 })); 43 }));
44 } 44 }
45 45
46 test("Basic", () { 46 test("Basic", () {
47 testZip([mks([1, 2, 3]), mks([4, 5, 6]), mks([7, 8, 9])], 47 testZip([mks([1, 2, 3]), mks([4, 5, 6]), mks([7, 8, 9])],
48 [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); 48 [[1, 4, 7], [2, 5, 8], [3, 6, 9]]);
49 }); 49 });
50 50
51 test("Uneven length 1", () { 51 test("Uneven length 1", () {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 Timer.run(() { controller.addError("BAD-6"); }); 148 Timer.run(() { controller.addError("BAD-6"); });
149 s.close(); 149 s.close();
150 }); 150 });
151 testZip([mks([1, 2, 3]).transform(trans), 151 testZip([mks([1, 2, 3]).transform(trans),
152 mks([4, 5, 6]).transform(trans), 152 mks([4, 5, 6]).transform(trans),
153 controller.stream], 153 controller.stream],
154 [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); 154 [[1, 4, 7], [2, 5, 8], [3, 6, 9]]);
155 }); 155 });
156 156
157 test("Pause/Resume", () { 157 test("Pause/Resume", () {
158 var done = expectAsync0((){}); // Call to complete test. 158 var done = expectAsync((){}); // Call to complete test.
159 159
160 int sc1p = 0; 160 int sc1p = 0;
161 StreamController c1 = new StreamController( 161 StreamController c1 = new StreamController(
162 onPause: () { 162 onPause: () {
163 sc1p++; 163 sc1p++;
164 }, 164 },
165 onResume: () { 165 onResume: () {
166 sc1p--; 166 sc1p--;
167 }); 167 });
168 168
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 c1..add(1)..add(3)..add(5)..add(7)..close(); 208 c1..add(1)..add(3)..add(5)..add(7)..close();
209 c2..add(2)..add(4); 209 c2..add(2)..add(4);
210 }); 210 });
211 211
212 test("pause-resume2", () { 212 test("pause-resume2", () {
213 var s1 = new Stream.fromIterable([0, 2, 4, 6, 8]); 213 var s1 = new Stream.fromIterable([0, 2, 4, 6, 8]);
214 var s2 = new Stream.fromIterable([1, 3, 5, 7]); 214 var s2 = new Stream.fromIterable([1, 3, 5, 7]);
215 var sz = new StreamZip([s1, s2]); 215 var sz = new StreamZip([s1, s2]);
216 int ctr = 0; 216 int ctr = 0;
217 var sub; 217 var sub;
218 sub = sz.listen(expectAsync1((v) { 218 sub = sz.listen(expectAsync((v) {
219 expect(v, equals([ctr * 2, ctr * 2 + 1])); 219 expect(v, equals([ctr * 2, ctr * 2 + 1]));
220 if (ctr == 1) { 220 if (ctr == 1) {
221 sub.pause(new Future.delayed(const Duration(milliseconds: 25))); 221 sub.pause(new Future.delayed(const Duration(milliseconds: 25)));
222 } else if (ctr == 2) { 222 } else if (ctr == 2) {
223 sub.pause(); 223 sub.pause();
224 new Future.delayed(const Duration(milliseconds: 25)).then((_) { 224 new Future.delayed(const Duration(milliseconds: 25)).then((_) {
225 sub.resume(); 225 sub.resume();
226 }); 226 });
227 } 227 }
228 ctr++; 228 ctr++;
229 }, count: 4)); 229 }, count: 4));
230 }); 230 });
231 } 231 }
OLDNEW
« no previous file with comments | « pkg/async/pubspec.yaml ('k') | pkg/async/test/stream_zip_zone_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698