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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 test('parses an anonymous stack frame correctly', () { | 67 test('parses an anonymous stack frame correctly', () { |
68 var frame = new Frame.parseV8( | 68 var frame = new Frame.parseV8( |
69 " at http://pub.dartlang.org/stuff.dart.js:560:28"); | 69 " at http://pub.dartlang.org/stuff.dart.js:560:28"); |
70 expect(frame.uri, | 70 expect(frame.uri, |
71 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 71 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
72 expect(frame.line, equals(560)); | 72 expect(frame.line, equals(560)); |
73 expect(frame.column, equals(28)); | 73 expect(frame.column, equals(28)); |
74 expect(frame.member, equals('<fn>')); | 74 expect(frame.member, equals('<fn>')); |
75 }); | 75 }); |
76 | 76 |
| 77 test('parses a stack frame with [as ...] correctly', () { |
| 78 // Ignore "[as ...]", since other stack trace formats don't support a |
| 79 // similar construct. |
| 80 var frame = new Frame.parseV8(" at VW.call\$0 [as call\$4] " |
| 81 "(http://pub.dartlang.org/stuff.dart.js:560:28)"); |
| 82 expect(frame.uri, |
| 83 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
| 84 expect(frame.line, equals(560)); |
| 85 expect(frame.column, equals(28)); |
| 86 expect(frame.member, equals('VW.call\$0')); |
| 87 }); |
| 88 |
77 test('converts "<anonymous>" to "<fn>"', () { | 89 test('converts "<anonymous>" to "<fn>"', () { |
78 String parsedMember(String member) => | 90 String parsedMember(String member) => |
79 new Frame.parseV8(' at $member (foo:0:0)').member; | 91 new Frame.parseV8(' at $member (foo:0:0)').member; |
80 | 92 |
81 expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); | 93 expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); |
82 expect(parsedMember('<anonymous>.<anonymous>.bar'), | 94 expect(parsedMember('<anonymous>.<anonymous>.bar'), |
83 equals('<fn>.<fn>.bar')); | 95 equals('<fn>.<fn>.bar')); |
84 }); | 96 }); |
85 | 97 |
86 test('throws a FormatException for malformed frames', () { | 98 test('throws a FormatException for malformed frames', () { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 equals('http://dartlang.org/thing.dart 5:10 in Foo')); | 308 equals('http://dartlang.org/thing.dart 5:10 in Foo')); |
297 }); | 309 }); |
298 | 310 |
299 test('converts "<anonymous closure>" to "<fn>"', () { | 311 test('converts "<anonymous closure>" to "<fn>"', () { |
300 expect(new Frame.parseVM('#0 Foo.<anonymous closure> ' | 312 expect(new Frame.parseVM('#0 Foo.<anonymous closure> ' |
301 '(dart:core/uri.dart:5:10)').toString(), | 313 '(dart:core/uri.dart:5:10)').toString(), |
302 equals('dart:core/uri.dart 5:10 in Foo.<fn>')); | 314 equals('dart:core/uri.dart 5:10 in Foo.<fn>')); |
303 }); | 315 }); |
304 }); | 316 }); |
305 } | 317 } |
OLD | NEW |