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

Side by Side Diff: sdk/lib/_internal/pub/test/error_group_test.dart

Issue 17490002: Make asBroadcastStream take two callbacks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reintroduce zone. Created 7 years, 6 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 | « sdk/lib/_internal/pub/lib/src/utils.dart ('k') | sdk/lib/async/stream.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 library error_group_test; 5 library error_group_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 }), completes); 200 }), completes);
201 }); 201 });
202 }); 202 });
203 203
204 group('with a single stream', () { 204 group('with a single stream', () {
205 StreamController controller; 205 StreamController controller;
206 Stream stream; 206 Stream stream;
207 207
208 setUp(() { 208 setUp(() {
209 errorGroup = new ErrorGroup(); 209 errorGroup = new ErrorGroup();
210 controller = new StreamController(sync: true); 210 controller = new StreamController.broadcast(sync: true);
211 stream = errorGroup.registerStream(controller.stream.asBroadcastStream()); 211 stream = errorGroup.registerStream(controller.stream);
212 }); 212 });
213 213
214 test('should pass through values from the stream', () { 214 test('should pass through values from the stream', () {
215 StreamIterator iter = new StreamIterator(stream); 215 StreamIterator iter = new StreamIterator(stream);
216 iter.moveNext().then((hasNext) { 216 iter.moveNext().then((hasNext) {
217 expect(hasNext, isTrue); 217 expect(hasNext, isTrue);
218 expect(iter.current, equals(1)); 218 expect(iter.current, equals(1));
219 iter.moveNext().then((hasNext) { 219 iter.moveNext().then((hasNext) {
220 expect(hasNext, isTrue); 220 expect(hasNext, isTrue);
221 expect(iter.current, equals(2)); 221 expect(iter.current, equals(2));
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 }); 321 });
322 322
323 group('with multiple streams', () { 323 group('with multiple streams', () {
324 StreamController controller1; 324 StreamController controller1;
325 StreamController controller2; 325 StreamController controller2;
326 Stream stream1; 326 Stream stream1;
327 Stream stream2; 327 Stream stream2;
328 328
329 setUp(() { 329 setUp(() {
330 errorGroup = new ErrorGroup(); 330 errorGroup = new ErrorGroup();
331 controller1 = new StreamController(sync: true); 331 controller1 = new StreamController.broadcast(sync: true);
332 controller2 = new StreamController(sync: true); 332 controller2 = new StreamController.broadcast(sync: true);
333 stream1 = errorGroup.registerStream(controller1.stream.asBroadcastStream() ); 333 stream1 = errorGroup.registerStream(controller1.stream);
334 stream2 = errorGroup.registerStream(controller2.stream.asBroadcastStream() ); 334 stream2 = errorGroup.registerStream(controller2.stream);
335 }); 335 });
336 336
337 test("should pipe exceptions from one stream to the other and to .done", 337 test("should pipe exceptions from one stream to the other and to .done",
338 () { 338 () {
339 expect(stream1.first, throwsFormatException); 339 expect(stream1.first, throwsFormatException);
340 expect(stream2.first, throwsFormatException); 340 expect(stream2.first, throwsFormatException);
341 expect(errorGroup.done, throwsFormatException); 341 expect(errorGroup.done, throwsFormatException);
342 342
343 controller1.addError(new FormatException()); 343 controller1.addError(new FormatException());
344 }); 344 });
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 }); 380 });
381 381
382 group('with a stream and a future', () { 382 group('with a stream and a future', () {
383 StreamController controller; 383 StreamController controller;
384 Stream stream; 384 Stream stream;
385 Completer completer; 385 Completer completer;
386 Future future; 386 Future future;
387 387
388 setUp(() { 388 setUp(() {
389 errorGroup = new ErrorGroup(); 389 errorGroup = new ErrorGroup();
390 controller = new StreamController(sync: true); 390 controller = new StreamController.broadcast(sync: true);
391 stream = errorGroup.registerStream(controller.stream.asBroadcastStream()); 391 stream = errorGroup.registerStream(controller.stream);
392 completer = new Completer(); 392 completer = new Completer();
393 future = errorGroup.registerFuture(completer.future); 393 future = errorGroup.registerFuture(completer.future);
394 }); 394 });
395 395
396 test("should pipe exceptions from the stream to the future", () { 396 test("should pipe exceptions from the stream to the future", () {
397 expect(stream.first, throwsFormatException); 397 expect(stream.first, throwsFormatException);
398 expect(future, throwsFormatException); 398 expect(future, throwsFormatException);
399 expect(errorGroup.done, throwsFormatException); 399 expect(errorGroup.done, throwsFormatException);
400 400
401 controller.addError(new FormatException()); 401 controller.addError(new FormatException());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 completion(equals(['value1', 'value2']))); 437 completion(equals(['value1', 'value2'])));
438 controller..add('value1')..add('value2')..close(); 438 controller..add('value1')..add('value2')..close();
439 439
440 expect(signal.future.then((_) { 440 expect(signal.future.then((_) {
441 // shouldn't cause a top-level exception 441 // shouldn't cause a top-level exception
442 completer.completeError(new FormatException()); 442 completer.completeError(new FormatException());
443 }), completes); 443 }), completes);
444 }); 444 });
445 }); 445 });
446 } 446 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/utils.dart ('k') | sdk/lib/async/stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698