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

Side by Side Diff: pkg/stack_trace/test/chain_test.dart

Issue 180223005: Add Chain.foldFrames to pkg/stack_trace. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/stack_trace/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) 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 ]); 380 ]);
381 381
382 expect(chain.terse.toString(), equals( 382 expect(chain.terse.toString(), equals(
383 '$userSlashCode 10:11 Foo.bar\n' 383 '$userSlashCode 10:11 Foo.bar\n'
384 'dart:core Bar.baz\n' 384 'dart:core Bar.baz\n'
385 '===== asynchronous gap ===========================\n' 385 '===== asynchronous gap ===========================\n'
386 '$userSlashCode 10:11 Foo.bar\n' 386 '$userSlashCode 10:11 Foo.bar\n'
387 'dart:core Bar.baz\n')); 387 'dart:core Bar.baz\n'));
388 }); 388 });
389 389
390 test("doesn't return in an empty chain", () { 390 test("doesn't return an empty chain", () {
391 var chain = new Chain([ 391 var chain = new Chain([
392 new Trace.parse( 392 new Trace.parse(
393 'dart:core 10:11 Foo.bar\n' 393 'dart:core 10:11 Foo.bar\n'
394 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n' 394 'package:stack_trace/stack_trace.dart 10:11 Bar.baz\n'
395 'dart:core 10:11 Zip.zap'), 395 'dart:core 10:11 Zip.zap'),
396 new Trace.parse( 396 new Trace.parse(
397 'dart:core 10:11 A.b\n' 397 'dart:core 10:11 A.b\n'
398 'package:stack_trace/stack_trace.dart 10:11 C.d\n' 398 'package:stack_trace/stack_trace.dart 10:11 C.d\n'
399 'dart:core 10:11 E.f') 399 'dart:core 10:11 E.f')
400 ]); 400 ]);
401 401
402 expect(chain.terse.toString(), equals('dart:core E.f\n')); 402 expect(chain.terse.toString(), equals('dart:core E.f\n'));
403 }); 403 });
404 }); 404 });
405 405
406 group('Chain.foldFrames', () {
407 test('folds each trace', () {
408 var chain = new Chain([
409 new Trace.parse(
410 'a.dart 10:11 Foo.bar\n'
411 'a.dart 10:11 Bar.baz\n'
412 'b.dart 10:11 Bang.qux\n'
413 'a.dart 10:11 Zip.zap\n'
414 'a.dart 10:11 Zop.zoop'),
415 new Trace.parse(
416 'a.dart 10:11 Foo.bar\n'
417 'a.dart 10:11 Bar.baz\n'
418 'a.dart 10:11 Bang.qux\n'
419 'a.dart 10:11 Zip.zap\n'
420 'b.dart 10:11 Zop.zoop')
421 ]);
422
423 var folded = chain.foldFrames((frame) => frame.library == 'a.dart');
424 expect(folded.toString(), equals(
425 'a.dart 10:11 Bar.baz\n'
426 'b.dart 10:11 Bang.qux\n'
427 'a.dart 10:11 Zop.zoop\n'
428 '===== asynchronous gap ===========================\n'
429 'a.dart 10:11 Zip.zap\n'
430 'b.dart 10:11 Zop.zoop\n'));
431 });
432
433 test('eliminates completely-folded traces', () {
434 var chain = new Chain([
435 new Trace.parse(
436 'a.dart 10:11 Foo.bar\n'
437 'b.dart 10:11 Bang.qux'),
438 new Trace.parse(
439 'a.dart 10:11 Foo.bar\n'
440 'a.dart 10:11 Bang.qux'),
441 new Trace.parse(
442 'a.dart 10:11 Zip.zap\n'
443 'b.dart 10:11 Zop.zoop')
444 ]);
445
446 var folded = chain.foldFrames((frame) => frame.library == 'a.dart');
447 expect(folded.toString(), equals(
448 'a.dart 10:11 Foo.bar\n'
449 'b.dart 10:11 Bang.qux\n'
450 '===== asynchronous gap ===========================\n'
451 'a.dart 10:11 Zip.zap\n'
452 'b.dart 10:11 Zop.zoop\n'));
453 });
454
455 test("doesn't return an empty trace", () {
456 var chain = new Chain([
457 new Trace.parse(
458 'a.dart 10:11 Foo.bar\n'
459 'a.dart 10:11 Bang.qux')
460 ]);
461
462 var folded = chain.foldFrames((frame) => frame.library == 'a.dart');
463 expect(folded.toString(), equals('a.dart 10:11 Bang.qux\n'));
464 });
465 });
466
406 test('Chain.toTrace eliminates asynchronous gaps', () { 467 test('Chain.toTrace eliminates asynchronous gaps', () {
407 var trace = new Chain([ 468 var trace = new Chain([
408 new Trace.parse( 469 new Trace.parse(
409 'user/code.dart 10:11 Foo.bar\n' 470 'user/code.dart 10:11 Foo.bar\n'
410 'dart:core 10:11 Bar.baz'), 471 'dart:core 10:11 Bar.baz'),
411 new Trace.parse( 472 new Trace.parse(
412 'user/code.dart 10:11 Foo.bar\n' 473 'user/code.dart 10:11 Foo.bar\n'
413 'dart:core 10:11 Bar.baz') 474 'dart:core 10:11 Bar.baz')
414 ]).toTrace(); 475 ]).toTrace();
415 476
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 /// 687 ///
627 /// [callback] is expected to throw the string `"error"`. 688 /// [callback] is expected to throw the string `"error"`.
628 Future<Chain> captureFuture(callback()) { 689 Future<Chain> captureFuture(callback()) {
629 var completer = new Completer<Chain>(); 690 var completer = new Completer<Chain>();
630 Chain.capture(callback, onError: (error, chain) { 691 Chain.capture(callback, onError: (error, chain) {
631 expect(error, equals('error')); 692 expect(error, equals('error'));
632 completer.complete(chain); 693 completer.complete(chain);
633 }); 694 });
634 return completer.future; 695 return completer.future;
635 } 696 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698