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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 'user/code.dart 10:11 Bang.qux\n' | 493 'user/code.dart 10:11 Bang.qux\n' |
494 'dart:core 10:11 Foo.bar\n' | 494 'dart:core 10:11 Foo.bar\n' |
495 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' | 495 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' |
496 'dart:core 10:11 Zip.zap\n' | 496 'dart:core 10:11 Zip.zap\n' |
497 'user/code.dart 10:11 Zop.zoop') | 497 'user/code.dart 10:11 Zop.zoop') |
498 ]); | 498 ]); |
499 | 499 |
500 expect(chain.terse.toString(), equals( | 500 expect(chain.terse.toString(), equals( |
501 'dart:core Bar.baz\n' | 501 'dart:core Bar.baz\n' |
502 '$userSlashCode 10:11 Bang.qux\n' | 502 '$userSlashCode 10:11 Bang.qux\n' |
503 'dart:core Zop.zoop\n' | |
504 '===== asynchronous gap ===========================\n' | 503 '===== asynchronous gap ===========================\n' |
505 '$userSlashCode 10:11 Bang.qux\n' | 504 '$userSlashCode 10:11 Bang.qux\n' |
506 'dart:core Zip.zap\n' | 505 'dart:core Zip.zap\n' |
507 '$userSlashCode 10:11 Zop.zoop\n')); | 506 '$userSlashCode 10:11 Zop.zoop\n')); |
508 }); | 507 }); |
509 | 508 |
510 test('eliminates internal-only traces', () { | 509 test('eliminates internal-only traces', () { |
511 var chain = new Chain([ | 510 var chain = new Chain([ |
512 new Trace.parse( | 511 new Trace.parse( |
513 'user/code.dart 10:11 Foo.bar\n' | 512 'user/code.dart 10:11 Foo.bar\n' |
514 'dart:core 10:11 Bar.baz'), | 513 'dart:core 10:11 Bar.baz'), |
515 new Trace.parse( | 514 new Trace.parse( |
516 'dart:core 10:11 Foo.bar\n' | 515 'dart:core 10:11 Foo.bar\n' |
517 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' | 516 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' |
518 'dart:core 10:11 Zip.zap'), | 517 'dart:core 10:11 Zip.zap'), |
519 new Trace.parse( | 518 new Trace.parse( |
520 'user/code.dart 10:11 Foo.bar\n' | 519 'user/code.dart 10:11 Foo.bar\n' |
521 'dart:core 10:11 Bar.baz') | 520 'dart:core 10:11 Bar.baz') |
522 ]); | 521 ]); |
523 | 522 |
524 expect(chain.terse.toString(), equals( | 523 expect(chain.terse.toString(), equals( |
525 '$userSlashCode 10:11 Foo.bar\n' | 524 '$userSlashCode 10:11 Foo.bar\n' |
526 'dart:core Bar.baz\n' | |
527 '===== asynchronous gap ===========================\n' | 525 '===== asynchronous gap ===========================\n' |
528 '$userSlashCode 10:11 Foo.bar\n' | 526 '$userSlashCode 10:11 Foo.bar\n')); |
529 'dart:core Bar.baz\n')); | |
530 }); | 527 }); |
531 | 528 |
532 test("doesn't return an empty chain", () { | 529 test("doesn't return an empty chain", () { |
533 var chain = new Chain([ | 530 var chain = new Chain([ |
534 new Trace.parse( | 531 new Trace.parse( |
535 'dart:core 10:11 Foo.bar\n' | 532 'dart:core 10:11 Foo.bar\n' |
536 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' | 533 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' |
537 'dart:core 10:11 Zip.zap'), | 534 'dart:core 10:11 Zip.zap'), |
538 new Trace.parse( | 535 new Trace.parse( |
539 'dart:core 10:11 A.b\n' | 536 'dart:core 10:11 A.b\n' |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 /// | 787 /// |
791 /// [callback] is expected to throw the string `"error"`. | 788 /// [callback] is expected to throw the string `"error"`. |
792 Future<Chain> captureFuture(callback()) { | 789 Future<Chain> captureFuture(callback()) { |
793 var completer = new Completer<Chain>(); | 790 var completer = new Completer<Chain>(); |
794 Chain.capture(callback, onError: (error, chain) { | 791 Chain.capture(callback, onError: (error, chain) { |
795 expect(error, equals('error')); | 792 expect(error, equals('error')); |
796 completer.complete(chain); | 793 completer.complete(chain); |
797 }); | 794 }); |
798 return completer.future; | 795 return completer.future; |
799 } | 796 } |
OLD | NEW |