| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // similar construct. | 142 // similar construct. |
| 143 var frame = new Frame.parseV8(" at VW.call\$0 [as call\$4] " | 143 var frame = new Frame.parseV8(" at VW.call\$0 [as call\$4] " |
| 144 "(http://pub.dartlang.org/stuff.dart.js:560:28)"); | 144 "(http://pub.dartlang.org/stuff.dart.js:560:28)"); |
| 145 expect(frame.uri, | 145 expect(frame.uri, |
| 146 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 146 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
| 147 expect(frame.line, equals(560)); | 147 expect(frame.line, equals(560)); |
| 148 expect(frame.column, equals(28)); | 148 expect(frame.column, equals(28)); |
| 149 expect(frame.member, equals('VW.call\$0')); | 149 expect(frame.member, equals('VW.call\$0')); |
| 150 }); | 150 }); |
| 151 | 151 |
| 152 test('parses a basic eval stack frame correctly', () { |
| 153 var frame = new Frame.parseV8(" at eval (eval at <anonymous> " |
| 154 "(http://pub.dartlang.org/stuff.dart.js:560:28))"); |
| 155 expect(frame.uri, |
| 156 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
| 157 expect(frame.line, equals(560)); |
| 158 expect(frame.column, equals(28)); |
| 159 expect(frame.member, equals('eval')); |
| 160 }); |
| 161 |
| 162 test('parses an eval stack frame with inner position info correctly', () { |
| 163 var frame = new Frame.parseV8(" at eval (eval at <anonymous> " |
| 164 "(http://pub.dartlang.org/stuff.dart.js:560:28), <anonymous>:3:28)"); |
| 165 expect(frame.uri, |
| 166 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
| 167 expect(frame.line, equals(560)); |
| 168 expect(frame.column, equals(28)); |
| 169 expect(frame.member, equals('eval')); |
| 170 }); |
| 171 |
| 172 test('parses a nested eval stack frame correctly', () { |
| 173 var frame = new Frame.parseV8(" at eval (eval at <anonymous> " |
| 174 "(eval at sub (http://pub.dartlang.org/stuff.dart.js:560:28)))"); |
| 175 expect(frame.uri, |
| 176 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
| 177 expect(frame.line, equals(560)); |
| 178 expect(frame.column, equals(28)); |
| 179 expect(frame.member, equals('eval')); |
| 180 }); |
| 181 |
| 152 test('converts "<anonymous>" to "<fn>"', () { | 182 test('converts "<anonymous>" to "<fn>"', () { |
| 153 String parsedMember(String member) => | 183 String parsedMember(String member) => |
| 154 new Frame.parseV8(' at $member (foo:0:0)').member; | 184 new Frame.parseV8(' at $member (foo:0:0)').member; |
| 155 | 185 |
| 156 expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); | 186 expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); |
| 157 expect(parsedMember('<anonymous>.<anonymous>.bar'), | 187 expect(parsedMember('<anonymous>.<anonymous>.bar'), |
| 158 equals('<fn>.<fn>.bar')); | 188 equals('<fn>.<fn>.bar')); |
| 159 }); | 189 }); |
| 160 | 190 |
| 161 test('throws a FormatException for malformed frames', () { | 191 test('throws a FormatException for malformed frames', () { |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 equals('dart:core/uri.dart 5 in Foo')); | 526 equals('dart:core/uri.dart 5 in Foo')); |
| 497 }); | 527 }); |
| 498 | 528 |
| 499 test('prints relative paths as relative', () { | 529 test('prints relative paths as relative', () { |
| 500 var relative = path.normalize('relative/path/to/foo.dart'); | 530 var relative = path.normalize('relative/path/to/foo.dart'); |
| 501 expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), | 531 expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), |
| 502 equals('$relative 5:10 in Foo')); | 532 equals('$relative 5:10 in Foo')); |
| 503 }); | 533 }); |
| 504 }); | 534 }); |
| 505 } | 535 } |
| OLD | NEW |