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

Side by Side Diff: test/chain/chain_test.dart

Issue 1492323004: Fix a crash in Chain.terse and Chain.foldFrames. (Closed) Base URL: git@github.com:dart-lang/stack_trace@master
Patch Set: Created 5 years 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 | « pubspec.yaml ('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) 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' 102 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n'
103 'dart:core 10:11 Zip.zap'), 103 'dart:core 10:11 Zip.zap'),
104 new Trace.parse( 104 new Trace.parse(
105 'dart:core 10:11 A.b\n' 105 'dart:core 10:11 A.b\n'
106 'package:stack_trace/stack_trace.dart 10:11 C.d\n' 106 'package:stack_trace/stack_trace.dart 10:11 C.d\n'
107 'dart:core 10:11 E.f') 107 'dart:core 10:11 E.f')
108 ]); 108 ]);
109 109
110 expect(chain.terse.toString(), equals('dart:core E.f\n')); 110 expect(chain.terse.toString(), equals('dart:core E.f\n'));
111 }); 111 });
112
113 // Regression test for #9
114 test("doesn't crash on empty traces", () {
115 var chain = new Chain([
116 new Trace.parse('user/code.dart 10:11 Bang.qux'),
117 new Trace([]),
118 new Trace.parse('user/code.dart 10:11 Bang.qux')
119 ]);
120
121 expect(chain.terse.toString(), equals(
122 '$userSlashCode 10:11 Bang.qux\n'
123 '===== asynchronous gap ===========================\n'
124 '$userSlashCode 10:11 Bang.qux\n'));
125 });
112 }); 126 });
113 127
114 group('Chain.foldFrames', () { 128 group('Chain.foldFrames', () {
115 test('folds each trace', () { 129 test('folds each trace', () {
116 var chain = new Chain([ 130 var chain = new Chain([
117 new Trace.parse( 131 new Trace.parse(
118 'a.dart 10:11 Foo.bar\n' 132 'a.dart 10:11 Foo.bar\n'
119 'a.dart 10:11 Bar.baz\n' 133 'a.dart 10:11 Bar.baz\n'
120 'b.dart 10:11 Bang.qux\n' 134 'b.dart 10:11 Bang.qux\n'
121 'a.dart 10:11 Zip.zap\n' 135 'a.dart 10:11 Zip.zap\n'
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 controller = new StreamController()..addError('error', trace); 287 controller = new StreamController()..addError('error', trace);
274 expect(Chain.track(controller.stream).toList() 288 expect(Chain.track(controller.stream).toList()
275 .catchError((e, stackTrace) { 289 .catchError((e, stackTrace) {
276 expect(e, equals('error')); 290 expect(e, equals('error'));
277 expect(stackTrace.toString(), equals(trace.toString())); 291 expect(stackTrace.toString(), equals(trace.toString()));
278 }), completes); 292 }), completes);
279 }); 293 });
280 }); 294 });
281 }); 295 });
282 } 296 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698