OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |