| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 chain_test; | 5 library chain_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 equals(new Trace.from(trace).toString())); | 472 equals(new Trace.from(trace).toString())); |
| 473 }); | 473 }); |
| 474 | 474 |
| 475 test('Chain.parse() parses a real Chain', () { | 475 test('Chain.parse() parses a real Chain', () { |
| 476 return captureFuture(() => inMicrotask(() => throw 'error')).then((chain) { | 476 return captureFuture(() => inMicrotask(() => throw 'error')).then((chain) { |
| 477 expect(new Chain.parse(chain.toString()).toString(), | 477 expect(new Chain.parse(chain.toString()).toString(), |
| 478 equals(chain.toString())); | 478 equals(chain.toString())); |
| 479 }); | 479 }); |
| 480 }); | 480 }); |
| 481 | 481 |
| 482 test("toString() ensures that all traces are aligned", () { |
| 483 var chain = new Chain([ |
| 484 new Trace.parse('short 10:11 Foo.bar\n'), |
| 485 new Trace.parse('loooooooooooong 10:11 Zop.zoop') |
| 486 ]); |
| 487 |
| 488 expect(chain.toString(), equals( |
| 489 'short 10:11 Foo.bar\n' |
| 490 '===== asynchronous gap ===========================\n' |
| 491 'loooooooooooong 10:11 Zop.zoop\n')); |
| 492 }); |
| 493 |
| 482 var userSlashCode = p.join('user', 'code.dart'); | 494 var userSlashCode = p.join('user', 'code.dart'); |
| 483 group('Chain.terse', () { | 495 group('Chain.terse', () { |
| 484 test('makes each trace terse', () { | 496 test('makes each trace terse', () { |
| 485 var chain = new Chain([ | 497 var chain = new Chain([ |
| 486 new Trace.parse( | 498 new Trace.parse( |
| 487 'dart:core 10:11 Foo.bar\n' | 499 'dart:core 10:11 Foo.bar\n' |
| 488 'dart:core 10:11 Bar.baz\n' | 500 'dart:core 10:11 Bar.baz\n' |
| 489 'user/code.dart 10:11 Bang.qux\n' | 501 'user/code.dart 10:11 Bang.qux\n' |
| 490 'dart:core 10:11 Zip.zap\n' | 502 'dart:core 10:11 Zip.zap\n' |
| 491 'dart:core 10:11 Zop.zoop'), | 503 'dart:core 10:11 Zop.zoop'), |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 /// | 799 /// |
| 788 /// [callback] is expected to throw the string `"error"`. | 800 /// [callback] is expected to throw the string `"error"`. |
| 789 Future<Chain> captureFuture(callback()) { | 801 Future<Chain> captureFuture(callback()) { |
| 790 var completer = new Completer<Chain>(); | 802 var completer = new Completer<Chain>(); |
| 791 Chain.capture(callback, onError: (error, chain) { | 803 Chain.capture(callback, onError: (error, chain) { |
| 792 expect(error, equals('error')); | 804 expect(error, equals('error')); |
| 793 completer.complete(chain); | 805 completer.complete(chain); |
| 794 }); | 806 }); |
| 795 return completer.future; | 807 return completer.future; |
| 796 } | 808 } |
| OLD | NEW |