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

Side by Side Diff: test/chain/chain_test.dart

Issue 1583483003: Add a "when" parameter to Chain.capture(). (Closed) Base URL: git@github.com:dart-lang/stack_trace@master
Patch Set: Created 4 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
« no previous file with comments | « pubspec.yaml ('k') | no next file » | 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) 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:path/path.dart' as p; 7 import 'package:path/path.dart' as p;
8 import 'package:stack_trace/stack_trace.dart'; 8 import 'package:stack_trace/stack_trace.dart';
9 import 'package:test/test.dart'; 9 import 'package:test/test.dart';
10 10
(...skipping 18 matching lines...) Expand all
29 var chain = new Chain.parse( 29 var chain = new Chain.parse(
30 '===== asynchronous gap ===========================\n' 30 '===== asynchronous gap ===========================\n'
31 '===== asynchronous gap ===========================\n'); 31 '===== asynchronous gap ===========================\n');
32 expect(chain.traces, hasLength(3)); 32 expect(chain.traces, hasLength(3));
33 expect(chain.traces[0].frames, isEmpty); 33 expect(chain.traces[0].frames, isEmpty);
34 expect(chain.traces[1].frames, isEmpty); 34 expect(chain.traces[1].frames, isEmpty);
35 expect(chain.traces[2].frames, isEmpty); 35 expect(chain.traces[2].frames, isEmpty);
36 }); 36 });
37 }); 37 });
38 38
39 group("Chain.capture() with when: false", () {
40 test("with no onError doesn't block errors", () {
41 expect(Chain.capture(() => new Future.error("oh no"), when: false),
42 throwsA("oh no"));
43 });
44
45 test("with onError blocks errors", () {
46 Chain.capture(() {
47 return new Future.error("oh no");
48 }, onError: expectAsync((error, chain) {
49 expect(error, equals("oh no"));
50 expect(chain, new isInstanceOf<Chain>());
51 }), when: false);
52 });
53 });
54
39 test("toString() ensures that all traces are aligned", () { 55 test("toString() ensures that all traces are aligned", () {
40 var chain = new Chain([ 56 var chain = new Chain([
41 new Trace.parse('short 10:11 Foo.bar\n'), 57 new Trace.parse('short 10:11 Foo.bar\n'),
42 new Trace.parse('loooooooooooong 10:11 Zop.zoop') 58 new Trace.parse('loooooooooooong 10:11 Zop.zoop')
43 ]); 59 ]);
44 60
45 expect(chain.toString(), equals( 61 expect(chain.toString(), equals(
46 'short 10:11 Foo.bar\n' 62 'short 10:11 Foo.bar\n'
47 '===== asynchronous gap ===========================\n' 63 '===== asynchronous gap ===========================\n'
48 'loooooooooooong 10:11 Zop.zoop\n')); 64 'loooooooooooong 10:11 Zop.zoop\n'));
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 controller = new StreamController()..addError('error', trace); 303 controller = new StreamController()..addError('error', trace);
288 expect(Chain.track(controller.stream).toList() 304 expect(Chain.track(controller.stream).toList()
289 .catchError((e, stackTrace) { 305 .catchError((e, stackTrace) {
290 expect(e, equals('error')); 306 expect(e, equals('error'));
291 expect(stackTrace.toString(), equals(trace.toString())); 307 expect(stackTrace.toString(), equals(trace.toString()));
292 }), completes); 308 }), completes);
293 }); 309 });
294 }); 310 });
295 }); 311 });
296 } 312 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698