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

Side by Side Diff: packages/stack_trace/test/chain/utils.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 stack_trace.test.chain.utils;
6
7 import 'dart:async'; 5 import 'dart:async';
8 6
9 import 'package:stack_trace/stack_trace.dart'; 7 import 'package:stack_trace/stack_trace.dart';
10 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
11 9
12 /// Runs [callback] in a microtask callback. 10 /// Runs [callback] in a microtask callback.
13 void inMicrotask(callback()) => scheduleMicrotask(callback); 11 void inMicrotask(callback()) => scheduleMicrotask(callback);
14 12
15 /// Runs [callback] in a one-shot timer callback. 13 /// Runs [callback] in a one-shot timer callback.
16 void inOneShotTimer(callback()) => Timer.run(callback); 14 void inOneShotTimer(callback()) => Timer.run(callback);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 63
66 /// Runs [callback] within [asyncFn], then converts any errors raised into a 64 /// Runs [callback] within [asyncFn], then converts any errors raised into a
67 /// [Chain] with [Chain.forTrace]. 65 /// [Chain] with [Chain.forTrace].
68 Future<Chain> chainForTrace(asyncFn(callback()), callback()) { 66 Future<Chain> chainForTrace(asyncFn(callback()), callback()) {
69 var completer = new Completer(); 67 var completer = new Completer();
70 asyncFn(() { 68 asyncFn(() {
71 // We use `new Future.value().then(...)` here as opposed to [new Future] or 69 // We use `new Future.value().then(...)` here as opposed to [new Future] or
72 // [new Future.sync] because those methods don't pass the exception through 70 // [new Future.sync] because those methods don't pass the exception through
73 // the zone specification before propagating it, so there's no chance to 71 // the zone specification before propagating it, so there's no chance to
74 // attach a chain to its stack trace. See issue 15105. 72 // attach a chain to its stack trace. See issue 15105.
75 new Future.value().then((_) => callback()) 73 new Future.value()
74 .then((_) => callback())
76 .catchError(completer.completeError); 75 .catchError(completer.completeError);
77 }); 76 });
77
78 // TODO(rnystrom): Remove this cast if catchError() gets a better type.
78 return completer.future 79 return completer.future
79 .catchError((_, stackTrace) => new Chain.forTrace(stackTrace)); 80 .catchError((_, stackTrace) => new Chain.forTrace(stackTrace))
81 as Future<Chain>;
80 } 82 }
81 83
82 /// Runs [callback] in a [Chain.capture] zone and returns a Future that 84 /// Runs [callback] in a [Chain.capture] zone and returns a Future that
83 /// completes to the stack chain for an error thrown by [callback]. 85 /// completes to the stack chain for an error thrown by [callback].
84 /// 86 ///
85 /// [callback] is expected to throw the string `"error"`. 87 /// [callback] is expected to throw the string `"error"`.
86 Future<Chain> captureFuture(callback()) { 88 Future<Chain> captureFuture(callback()) {
87 var completer = new Completer<Chain>(); 89 var completer = new Completer<Chain>();
88 Chain.capture(callback, onError: (error, chain) { 90 Chain.capture(callback, onError: (error, chain) {
89 expect(error, equals('error')); 91 expect(error, equals('error'));
90 completer.complete(chain); 92 completer.complete(chain);
91 }); 93 });
92 return completer.future; 94 return completer.future;
93 } 95 }
OLDNEW
« no previous file with comments | « packages/stack_trace/test/chain/dart2js_test.dart ('k') | packages/stack_trace/test/chain/vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698