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

Side by Side Diff: test/chain_test.dart

Issue 1171873002: Support parsing empty stack chains. (Closed) Base URL: git@github.com:dart-lang/stack_trace@master
Patch Set: Created 5 years, 6 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 | « lib/src/trace.dart ('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) 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 trace = stackTrace; 465 trace = stackTrace;
466 return new Chain.forTrace(stackTrace); 466 return new Chain.forTrace(stackTrace);
467 } 467 }
468 }); 468 });
469 469
470 expect(chain.traces, hasLength(1)); 470 expect(chain.traces, hasLength(1));
471 expect(chain.traces.first.toString(), 471 expect(chain.traces.first.toString(),
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 group('Chain.parse()', () {
476 return captureFuture(() => inMicrotask(() => throw 'error')).then((chain) { 476 test('parses a real Chain', () {
477 expect(new Chain.parse(chain.toString()).toString(), 477 return captureFuture(() => inMicrotask(() => throw 'error'))
478 equals(chain.toString())); 478 .then((chain) {
479 expect(new Chain.parse(chain.toString()).toString(),
480 equals(chain.toString()));
481 });
482 });
483
484 test('parses an empty string', () {
485 var chain = new Chain.parse('');
486 expect(chain.traces, isEmpty);
487 });
488
489 test('parses a chain containing empty traces', () {
490 var chain = new Chain.parse(
491 '===== asynchronous gap ===========================\n'
492 '===== asynchronous gap ===========================\n');
493 expect(chain.traces, hasLength(3));
494 expect(chain.traces[0].frames, isEmpty);
495 expect(chain.traces[1].frames, isEmpty);
496 expect(chain.traces[2].frames, isEmpty);
479 }); 497 });
480 }); 498 });
481 499
482 test("toString() ensures that all traces are aligned", () { 500 test("toString() ensures that all traces are aligned", () {
483 var chain = new Chain([ 501 var chain = new Chain([
484 new Trace.parse('short 10:11 Foo.bar\n'), 502 new Trace.parse('short 10:11 Foo.bar\n'),
485 new Trace.parse('loooooooooooong 10:11 Zop.zoop') 503 new Trace.parse('loooooooooooong 10:11 Zop.zoop')
486 ]); 504 ]);
487 505
488 expect(chain.toString(), equals( 506 expect(chain.toString(), equals(
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 /// 817 ///
800 /// [callback] is expected to throw the string `"error"`. 818 /// [callback] is expected to throw the string `"error"`.
801 Future<Chain> captureFuture(callback()) { 819 Future<Chain> captureFuture(callback()) {
802 var completer = new Completer<Chain>(); 820 var completer = new Completer<Chain>();
803 Chain.capture(callback, onError: (error, chain) { 821 Chain.capture(callback, onError: (error, chain) {
804 expect(error, equals('error')); 822 expect(error, equals('error'));
805 completer.complete(chain); 823 completer.complete(chain);
806 }); 824 });
807 return completer.future; 825 return completer.future;
808 } 826 }
OLDNEW
« no previous file with comments | « lib/src/trace.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698