| 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 frame_test; | 5 library frame_test; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
| 8 import 'package:stack_trace/stack_trace.dart'; | 8 import 'package:stack_trace/stack_trace.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 test('parses a stack frame without column correctly', () { | 23 test('parses a stack frame without column correctly', () { |
| 24 var frame = new Frame.parseVM("#1 Foo._bar " | 24 var frame = new Frame.parseVM("#1 Foo._bar " |
| 25 "(file:///home/nweiz/code/stuff.dart:24)"); | 25 "(file:///home/nweiz/code/stuff.dart:24)"); |
| 26 expect(frame.uri, | 26 expect(frame.uri, |
| 27 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); | 27 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); |
| 28 expect(frame.line, equals(24)); | 28 expect(frame.line, equals(24)); |
| 29 expect(frame.column, null); | 29 expect(frame.column, null); |
| 30 expect(frame.member, equals('Foo._bar')); | 30 expect(frame.member, equals('Foo._bar')); |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 // This can happen with async stack traces. See issue 22009. |
| 34 test('parses a stack frame without line or column correctly', () { |
| 35 var frame = new Frame.parseVM("#1 Foo._bar " |
| 36 "(file:///home/nweiz/code/stuff.dart)"); |
| 37 expect(frame.uri, |
| 38 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); |
| 39 expect(frame.line, isNull); |
| 40 expect(frame.column, isNull); |
| 41 expect(frame.member, equals('Foo._bar')); |
| 42 }); |
| 43 |
| 33 test('converts "<anonymous closure>" to "<fn>"', () { | 44 test('converts "<anonymous closure>" to "<fn>"', () { |
| 34 String parsedMember(String member) => | 45 String parsedMember(String member) => |
| 35 new Frame.parseVM('#0 $member (foo:0:0)').member; | 46 new Frame.parseVM('#0 $member (foo:0:0)').member; |
| 36 | 47 |
| 37 expect(parsedMember('Foo.<anonymous closure>'), equals('Foo.<fn>')); | 48 expect(parsedMember('Foo.<anonymous closure>'), equals('Foo.<fn>')); |
| 38 expect(parsedMember('<anonymous closure>.<anonymous closure>.bar'), | 49 expect(parsedMember('<anonymous closure>.<anonymous closure>.bar'), |
| 39 equals('<fn>.<fn>.bar')); | 50 equals('<fn>.<fn>.bar')); |
| 40 }); | 51 }); |
| 41 | 52 |
| 53 test('converts "<<anonymous closure>_async_body>" to "<async>"', () { |
| 54 var frame = new Frame.parseVM( |
| 55 '#0 Foo.<<anonymous closure>_async_body> (foo:0:0)'); |
| 56 expect(frame.member, equals('Foo.<async>')); |
| 57 }); |
| 58 |
| 59 test('converts "<<anonymous closure>_async_body>" to "<async>"', () { |
| 60 var frame = new Frame.parseVM( |
| 61 '#0 Foo.<<anonymous closure>_async_body> (foo:0:0)'); |
| 62 expect(frame.member, equals('Foo.<async>')); |
| 63 }); |
| 64 |
| 42 test('parses a folded frame correctly', () { | 65 test('parses a folded frame correctly', () { |
| 43 var frame = new Frame.parseVM('...'); | 66 var frame = new Frame.parseVM('...'); |
| 44 | 67 |
| 45 expect(frame.member, equals('...')); | 68 expect(frame.member, equals('...')); |
| 46 expect(frame.uri, equals(new Uri())); | 69 expect(frame.uri, equals(new Uri())); |
| 47 expect(frame.line, isNull); | 70 expect(frame.line, isNull); |
| 48 expect(frame.column, isNull); | 71 expect(frame.column, isNull); |
| 49 }); | 72 }); |
| 50 | 73 |
| 51 test('throws a FormatException for malformed frames', () { | 74 test('throws a FormatException for malformed frames', () { |
| 52 expect(() => new Frame.parseVM(''), throwsFormatException); | 75 expect(() => new Frame.parseVM(''), throwsFormatException); |
| 53 expect(() => new Frame.parseVM('#1'), throwsFormatException); | 76 expect(() => new Frame.parseVM('#1'), throwsFormatException); |
| 54 expect(() => new Frame.parseVM('#1 Foo'), throwsFormatException); | 77 expect(() => new Frame.parseVM('#1 Foo'), throwsFormatException); |
| 55 expect(() => new Frame.parseVM('#1 Foo (dart:async/future.dart)'), | |
| 56 throwsFormatException); | |
| 57 expect(() => new Frame.parseVM('#1 (dart:async/future.dart:10:15)'), | 78 expect(() => new Frame.parseVM('#1 (dart:async/future.dart:10:15)'), |
| 58 throwsFormatException); | 79 throwsFormatException); |
| 59 expect(() => new Frame.parseVM('Foo (dart:async/future.dart:10:15)'), | 80 expect(() => new Frame.parseVM('Foo (dart:async/future.dart:10:15)'), |
| 60 throwsFormatException); | 81 throwsFormatException); |
| 61 }); | 82 }); |
| 62 }); | 83 }); |
| 63 | 84 |
| 64 group('.parseV8', () { | 85 group('.parseV8', () { |
| 65 test('parses a stack frame correctly', () { | 86 test('parses a stack frame correctly', () { |
| 66 var frame = new Frame.parseV8(" at VW.call\$0 " | 87 var frame = new Frame.parseV8(" at VW.call\$0 " |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 equals('dart:core/uri.dart 5 in Foo')); | 546 equals('dart:core/uri.dart 5 in Foo')); |
| 526 }); | 547 }); |
| 527 | 548 |
| 528 test('prints relative paths as relative', () { | 549 test('prints relative paths as relative', () { |
| 529 var relative = path.normalize('relative/path/to/foo.dart'); | 550 var relative = path.normalize('relative/path/to/foo.dart'); |
| 530 expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), | 551 expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), |
| 531 equals('$relative 5:10 in Foo')); | 552 equals('$relative 5:10 in Foo')); |
| 532 }); | 553 }); |
| 533 }); | 554 }); |
| 534 } | 555 } |
| OLD | NEW |