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

Side by Side Diff: tests/lib_2/async/catch_errors.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/lib.status ('k') | tests/lib_2/async/catch_errors18_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 library catch_errors;
2
3 import 'dart:async';
4
5 Stream catchErrors(void body()) {
6 StreamController controller;
7
8 bool onError(e, st) {
9 controller.add(e);
10 return true;
11 }
12
13 void onListen() {
14 runZoned(body, onError: onError);
15 }
16
17 controller = new StreamController(onListen: onListen);
18 return controller.stream;
19 }
20
21 runZonedScheduleMicrotask(body(),
22 {void onScheduleMicrotask(void callback()), Function onError}) {
23 if (onScheduleMicrotask == null) {
24 return runZoned(body, onError: onError);
25 }
26 HandleUncaughtErrorHandler errorHandler;
27 if (onError != null) {
28 errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error,
29 StackTrace stackTrace) {
30 try {
31 return self.parent.runUnary(onError, error);
32 } catch (e, s) {
33 if (identical(e, error)) {
34 return parent.handleUncaughtError(zone, error, stackTrace);
35 } else {
36 return parent.handleUncaughtError(zone, e, s);
37 }
38 }
39 };
40 }
41 ScheduleMicrotaskHandler asyncHandler;
42 if (onScheduleMicrotask != null) {
43 asyncHandler = (Zone self, ZoneDelegate parent, Zone zone, f()) {
44 self.parent.runUnary(onScheduleMicrotask, () => zone.runGuarded(f));
45 };
46 }
47 ZoneSpecification specification = new ZoneSpecification(
48 handleUncaughtError: errorHandler, scheduleMicrotask: asyncHandler);
49 Zone zone = Zone.current.fork(specification: specification);
50 if (onError != null) {
51 return zone.runGuarded(body);
52 } else {
53 return zone.run(body);
54 }
55 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib_2/async/catch_errors18_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698