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

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

Issue 2993213003: Migrated test block 167 to Dart 2.0. (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « tests/lib/async/catch_errors25_test.dart ('k') | tests/lib/async/catch_errors27_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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:async_helper/async_helper.dart';
6 import "package:expect/expect.dart";
7 import 'dart:async';
8 import 'catch_errors.dart';
9
10 main() {
11 asyncStart();
12 Completer done = new Completer();
13
14 var events = [];
15 StreamController controller;
16 Stream stream;
17 // Test `StreamController.broadcast` streams.
18 catchErrors(() {
19 catchErrors(() {
20 controller = new StreamController.broadcast();
21
22 // Listen to the stream from the inner zone.
23 controller.stream.map((x) {
24 events.add("map $x");
25 return x + 100;
26 }).transform(
27 new StreamTransformer.fromHandlers(handleError: (e, st, sink) {
28 sink.add("error $e");
29 })).listen((x) {
30 events.add("stream $x");
31 });
32 })
33 .listen((x) {
34 events.add(x);
35 })
36 .asFuture()
37 .then((_) {
38 Expect.fail("Unexpected callback");
39 });
40
41 // Listen to the stream from the outer zone.
42 controller.stream.listen((x) {
43 events.add("stream2 $x");
44 }, onError: (x) {
45 events.add("stream2 error $x");
46 });
47
48 // Feed the controller.
49 controller.add(1);
50 controller.addError("inner stream");
51 new Future.error("outer error");
52 controller.close();
53 }).listen((x) {
54 events.add("outer: $x");
55 if (x == "outer error") done.complete(true);
56 }, onDone: () {
57 Expect.fail("Unexpected callback");
58 });
59
60 done.future.whenComplete(() {
61 // Give handlers time to run.
62 Timer.run(() {
63 Expect.listEquals([
64 "map 1",
65 "stream 101",
66 "stream2 1",
67 "stream error inner stream",
68 "stream2 error inner stream",
69 "outer: outer error",
70 ], events);
71 asyncEnd();
72 });
73 });
74 }
OLDNEW
« no previous file with comments | « tests/lib/async/catch_errors25_test.dart ('k') | tests/lib/async/catch_errors27_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698