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

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

Issue 366813005: Don't consider controller.addError to be a zone-crossing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add a new test. Created 6 years, 5 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
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 'package:async_helper/async_helper.dart'; 5 import 'package:async_helper/async_helper.dart';
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import 'dart:async'; 7 import 'dart:async';
8 import 'catch_errors.dart'; 8 import 'catch_errors.dart';
9 9
10 main() { 10 main() {
(...skipping 15 matching lines...) Expand all
26 return x + 100; 26 return x + 100;
27 }) 27 })
28 .transform(new StreamTransformer.fromHandlers( 28 .transform(new StreamTransformer.fromHandlers(
29 handleError: (e, st, sink) { sink.add("error $e"); })) 29 handleError: (e, st, sink) { sink.add("error $e"); }))
30 .asBroadcastStream(); 30 .asBroadcastStream();
31 stream.listen((x) { events.add("stream $x"); }); 31 stream.listen((x) { events.add("stream $x"); });
32 }).listen((x) { events.add(x); }) 32 }).listen((x) { events.add(x); })
33 .asFuture().then((_) { Expect.fail("Unexpected callback"); }); 33 .asFuture().then((_) { Expect.fail("Unexpected callback"); });
34 stream.listen((x) { events.add("stream2 $x"); }); 34 stream.listen((x) { events.add("stream2 $x"); });
35 controller.add(1); 35 controller.add(1);
36 // Errors are not allowed to traverse boundaries. This error should be 36 // `addError` does not count as zone-traversal. It should be caught by
37 // caught by the outer catchErrors. 37 // the inner error handler.
38 controller.addError(2); 38 controller.addError("inner error");
39 new Future.error("caught by outer");
39 controller.close(); 40 controller.close();
40 }).listen((x) { 41 }).listen((x) {
41 events.add("outer: $x"); 42 events.add("outer: $x");
42 if (x == 2) done.complete(true); 43 if (x == "caught by outer") done.complete(true);
43 }, 44 },
44 onDone: () { Expect.fail("Unexpected callback"); }); 45 onDone: () { Expect.fail("Unexpected callback"); });
45 46
46 done.future.whenComplete(() { 47 done.future.whenComplete(() {
47 // Give handlers time to run. 48 // Give handlers time to run.
48 Timer.run(() { 49 Timer.run(() {
49 Expect.listEquals(["map 1", 50 Expect.listEquals(["map 1",
50 "stream 101", 51 "stream 101",
51 "stream2 101", 52 "stream2 101",
52 "outer: 2", 53 "stream error inner error",
54 "stream2 error inner error",
55 "outer: caught by outer",
53 ], 56 ],
54 events); 57 events);
55 asyncEnd(); 58 asyncEnd();
56 }); 59 });
57 }); 60 });
58 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698