Chromium Code Reviews| 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 |
| 11 import 'utils.dart'; | 11 import 'utils.dart'; |
| 12 | 12 |
| 13 typedef void ChainErrorCallback(stack, Chain chain); | |
| 14 | |
| 13 void main() { | 15 void main() { |
| 14 group('Chain.parse()', () { | 16 group('Chain.parse()', () { |
| 15 test('parses a real Chain', () { | 17 test('parses a real Chain', () { |
| 16 return captureFuture(() => inMicrotask(() => throw 'error')) | 18 return captureFuture(() => inMicrotask(() => throw 'error')) |
| 17 .then((chain) { | 19 .then((chain) { |
| 18 expect(new Chain.parse(chain.toString()).toString(), | 20 expect(new Chain.parse(chain.toString()).toString(), |
| 19 equals(chain.toString())); | 21 equals(chain.toString())); |
| 20 }); | 22 }); |
| 21 }); | 23 }); |
| 22 | 24 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 41 expect(Chain.capture(() => new Future.error("oh no"), when: false), | 43 expect(Chain.capture(() => new Future.error("oh no"), when: false), |
| 42 throwsA("oh no")); | 44 throwsA("oh no")); |
| 43 }); | 45 }); |
| 44 | 46 |
| 45 test("with onError blocks errors", () { | 47 test("with onError blocks errors", () { |
| 46 Chain.capture(() { | 48 Chain.capture(() { |
| 47 return new Future.error("oh no"); | 49 return new Future.error("oh no"); |
| 48 }, onError: expectAsync((error, chain) { | 50 }, onError: expectAsync((error, chain) { |
| 49 expect(error, equals("oh no")); | 51 expect(error, equals("oh no")); |
| 50 expect(chain, new isInstanceOf<Chain>()); | 52 expect(chain, new isInstanceOf<Chain>()); |
| 51 }), when: false); | 53 }) as ChainErrorCallback, when: false); |
| 54 // TODO(rnystrom): Remove this cast if expectAsync() gets a better type. | |
|
nweiz
2016/04/08 00:24:03
I generally haven't been making tests strong mode
| |
| 52 }); | 55 }); |
| 53 }); | 56 }); |
| 54 | 57 |
| 55 test("toString() ensures that all traces are aligned", () { | 58 test("toString() ensures that all traces are aligned", () { |
| 56 var chain = new Chain([ | 59 var chain = new Chain([ |
| 57 new Trace.parse('short 10:11 Foo.bar\n'), | 60 new Trace.parse('short 10:11 Foo.bar\n'), |
| 58 new Trace.parse('loooooooooooong 10:11 Zop.zoop') | 61 new Trace.parse('loooooooooooong 10:11 Zop.zoop') |
| 59 ]); | 62 ]); |
| 60 | 63 |
| 61 expect(chain.toString(), equals( | 64 expect(chain.toString(), equals( |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 controller = new StreamController()..addError('error', trace); | 306 controller = new StreamController()..addError('error', trace); |
| 304 expect(Chain.track(controller.stream).toList() | 307 expect(Chain.track(controller.stream).toList() |
| 305 .catchError((e, stackTrace) { | 308 .catchError((e, stackTrace) { |
| 306 expect(e, equals('error')); | 309 expect(e, equals('error')); |
| 307 expect(stackTrace.toString(), equals(trace.toString())); | 310 expect(stackTrace.toString(), equals(trace.toString())); |
| 308 }), completes); | 311 }), completes); |
| 309 }); | 312 }); |
| 310 }); | 313 }); |
| 311 }); | 314 }); |
| 312 } | 315 } |
| OLD | NEW |