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

Side by Side Diff: tests/lib/async/stream_controller_async_test.dart

Issue 11862008: Make Streams also cosider a thrown AsyncError a rethrow. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address reciew comments. 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
« no previous file with comments | « sdk/lib/async/stream_pipe.dart ('k') | tests/lib/async/stream_controller_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) 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 // Test the basic StreamController and StreamController.singleSubscription. 5 // Test the basic StreamController and StreamController.singleSubscription.
6 library stream_controller_async_test; 6 library stream_controller_async_test;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import '../../../pkg/unittest/lib/unittest.dart'; 10 import '../../../pkg/unittest/lib/unittest.dart';
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 completer.complete(); 387 completer.complete();
388 Expect.listEquals(expectedEvents.events, actualEvents.events); 388 Expect.listEquals(expectedEvents.events, actualEvents.events);
389 expectedEvents..add(43)..add(44)..close(); 389 expectedEvents..add(43)..add(44)..close();
390 actualEvents.onDone(expectAsync0(() { 390 actualEvents.onDone(expectAsync0(() {
391 Expect.listEquals(expectedEvents.events, actualEvents.events); 391 Expect.listEquals(expectedEvents.events, actualEvents.events);
392 })); 392 }));
393 actualEvents.resume(); 393 actualEvents.resume();
394 }); 394 });
395 } 395 }
396 396
397 testRethrow() {
398 AsyncError error = new AsyncError("UNIQUE", "UNIQUE");
399
400 testStream(name, streamValueTransform) {
401 test("rethrow-$name-value", () {
402 StreamController c = new StreamController();
403 Stream s = streamValueTransform(c.stream, (v) { throw error; });
404 s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync1(
405 (AsyncError e) { Expect.identical(error, e); }));
406 c.add(null);
407 c.close();
408 });
409 }
410
411 testStreamError(name, streamErrorTransform) {
412 test("rethrow-$name-error", () {
413 StreamController c = new StreamController();
414 Stream s = streamErrorTransform(c.stream, (e) { throw error; });
415 s.listen((_) { Expect.fail("unexpected value"); }, onError: expectAsync1(
416 (AsyncError e) { Expect.identical(error, e); }));
417 c.signalError(null);
418 c.close();
419 });
420 }
421
422 testFuture(name, streamValueTransform) {
423 test("rethrow-$name-value", () {
424 StreamController c = new StreamController();
425 Future f = streamValueTransform(c.stream, (v) { throw error; });
426 f.then((v) { Expect.fail("unreachable"); },
427 onError: expectAsync1((e) { Expect.identical(error, e); }));
428 // Need two values to trigger compare for min/max.
429 c.add(0);
430 c.add(1);
431 c.close();
432 });
433 }
434
435 testStream("where", (s, act) => s.where(act));
436 testStream("mappedBy", (s, act) => s.mappedBy(act));
437 testStream("expand", (s, act) => s.expand(act));
438 testStream("where", (s, act) => s.where(act));
439 testStreamError("handleError", (s, act) => s.handleError(act));
440 testStreamError("handleTest", (s, act) => s.handleError((v) {}, test: act));
441 testFuture("every", (s, act) => s.every(act));
442 testFuture("any", (s, act) => s.any(act));
443 testFuture("min", (s, act) => s.min((a, b) => act(b)));
444 testFuture("max", (s, act) => s.max((a, b) => act(b)));
445 testFuture("reduce", (s, act) => s.reduce(0, (a,b) => act(b)));
446 }
447
397 main() { 448 main() {
398 testController(); 449 testController();
399 testSingleController(); 450 testSingleController();
400 testExtraMethods(); 451 testExtraMethods();
401 testPause(); 452 testPause();
453 testRethrow();
402 } 454 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream_pipe.dart ('k') | tests/lib/async/stream_controller_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698