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

Side by Side Diff: test/frame_test.dart

Issue 2739643004: Fix friendly frame parsing bugs. (Closed)
Patch Set: Fix friendly frame parsing bugs. Created 3 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
« no previous file with comments | « pubspec.yaml ('k') | test/trace_test.dart » ('j') | 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 import 'package:path/path.dart' as path; 5 import 'package:path/path.dart' as path;
6 import 'package:stack_trace/stack_trace.dart'; 6 import 'package:stack_trace/stack_trace.dart';
7 import 'package:test/test.dart'; 7 import 'package:test/test.dart';
8 8
9 void main() { 9 void main() {
10 group('.parseVM', () { 10 group('.parseVM', () {
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 441
442 test('parses a stack frame with no line or column correctly', () { 442 test('parses a stack frame with no line or column correctly', () {
443 var frame = new Frame.parseFriendly( 443 var frame = new Frame.parseFriendly(
444 "http://dartlang.org/foo/bar.dart Foo.<fn>.bar"); 444 "http://dartlang.org/foo/bar.dart Foo.<fn>.bar");
445 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); 445 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
446 expect(frame.line, isNull); 446 expect(frame.line, isNull);
447 expect(frame.column, isNull); 447 expect(frame.column, isNull);
448 expect(frame.member, equals('Foo.<fn>.bar')); 448 expect(frame.member, equals('Foo.<fn>.bar'));
449 }); 449 });
450 450
451 test('parses a stack frame with no line correctly', () { 451 test('parses a stack frame with no column correctly', () {
452 var frame = new Frame.parseFriendly( 452 var frame = new Frame.parseFriendly(
453 "http://dartlang.org/foo/bar.dart 10 Foo.<fn>.bar"); 453 "http://dartlang.org/foo/bar.dart 10 Foo.<fn>.bar");
454 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); 454 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
455 expect(frame.line, equals(10)); 455 expect(frame.line, equals(10));
456 expect(frame.column, isNull); 456 expect(frame.column, isNull);
457 expect(frame.member, equals('Foo.<fn>.bar')); 457 expect(frame.member, equals('Foo.<fn>.bar'));
458 }); 458 });
459 459
460 test('parses a stack frame with a relative path correctly', () { 460 test('parses a stack frame with a relative path correctly', () {
461 var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar"); 461 var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar");
462 expect(frame.uri, equals( 462 expect(frame.uri, equals(
463 path.toUri(path.absolute(path.join('foo', 'bar.dart'))))); 463 path.toUri(path.absolute(path.join('foo', 'bar.dart')))));
464 expect(frame.line, equals(10)); 464 expect(frame.line, equals(10));
465 expect(frame.column, equals(11)); 465 expect(frame.column, equals(11));
466 expect(frame.member, equals('Foo.<fn>.bar')); 466 expect(frame.member, equals('Foo.<fn>.bar'));
467 }); 467 });
468 468
469 test('returns an UnparsedFrame for malformed frames', () { 469 test('returns an UnparsedFrame for malformed frames', () {
470 expectIsUnparsed((text) => new Frame.parseFriendly(text), ''); 470 expectIsUnparsed((text) => new Frame.parseFriendly(text), '');
471 expectIsUnparsed((text) => new Frame.parseFriendly(text), 'foo/bar.dart'); 471 expectIsUnparsed((text) => new Frame.parseFriendly(text), 'foo/bar.dart');
472 expectIsUnparsed((text) => new Frame.parseFriendly(text), 472 expectIsUnparsed((text) => new Frame.parseFriendly(text),
473 'foo/bar.dart 10:11'); 473 'foo/bar.dart 10:11');
474 }); 474 });
475
476 test('parses a data url stack frame with no line or column correctly', () {
477 var frame = new Frame.parseFriendly(
478 "data:... main");
479 expect(frame.uri.scheme, equals('data'));
480 expect(frame.line, isNull);
481 expect(frame.column, isNull);
482 expect(frame.member, equals('main'));
483 });
484
485 test('parses a data url stack frame correctly', () {
486 var frame = new Frame.parseFriendly(
487 "data:... 10:11 main");
488 expect(frame.uri.scheme, equals('data'));
489 expect(frame.line, equals(10));
490 expect(frame.column, equals(11));
491 expect(frame.member, equals('main'));
492 });
493
494 test('parses a stack frame with spaces in the member name correctly', () {
495 var frame = new Frame.parseFriendly(
496 "foo/bar.dart 10:11 (anonymous function).dart.fn");
497 expect(frame.uri,
498 equals(path.toUri(path.absolute(path.join('foo', 'bar.dart')))));
499 expect(frame.line, equals(10));
500 expect(frame.column, equals(11));
501 expect(frame.member, equals('(anonymous function).dart.fn'));
502 });
503
504 test('parses a stack frame with spaces in the member name and no line or '
505 'column correctly', () {
506 var frame = new Frame.parseFriendly(
507 "http://dartlang.org/foo/bar.dart (anonymous function).dart.fn");
508 expect(
509 frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
510 expect(frame.line, isNull);
511 expect(frame.column, isNull);
512 expect(frame.member, equals('(anonymous function).dart.fn'));
513 });
475 }); 514 });
476 515
477 test('only considers dart URIs to be core', () { 516 test('only considers dart URIs to be core', () {
478 bool isCore(String library) => 517 bool isCore(String library) =>
479 new Frame.parseVM('#0 Foo ($library:0:0)').isCore; 518 new Frame.parseVM('#0 Foo ($library:0:0)').isCore;
480 519
481 expect(isCore('dart:core'), isTrue); 520 expect(isCore('dart:core'), isTrue);
482 expect(isCore('dart:async'), isTrue); 521 expect(isCore('dart:async'), isTrue);
483 expect(isCore('dart:core/uri.dart'), isTrue); 522 expect(isCore('dart:core/uri.dart'), isTrue);
484 expect(isCore('dart:async/future.dart'), isTrue); 523 expect(isCore('dart:async/future.dart'), isTrue);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 equals('$relative 5:10 in Foo')); 601 equals('$relative 5:10 in Foo'));
563 }); 602 });
564 }); 603 });
565 } 604 }
566 605
567 void expectIsUnparsed(Frame constructor(String text), String text) { 606 void expectIsUnparsed(Frame constructor(String text), String text) {
568 var frame = constructor(text); 607 var frame = constructor(text);
569 expect(frame, new isInstanceOf<UnparsedFrame>()); 608 expect(frame, new isInstanceOf<UnparsedFrame>());
570 expect(frame.toString(), equals(text)); 609 expect(frame.toString(), equals(text));
571 } 610 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/trace_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698