| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library frame_test; | |
| 6 | |
| 7 import 'package:path/path.dart' as path; | |
| 8 import 'package:stack_trace/stack_trace.dart'; | |
| 9 import 'package:unittest/unittest.dart'; | |
| 10 | |
| 11 void main() { | |
| 12 group('.parseVM', () { | |
| 13 test('parses a stack frame with column correctly', () { | |
| 14 var frame = new Frame.parseVM("#1 Foo._bar " | |
| 15 "(file:///home/nweiz/code/stuff.dart:42:21)"); | |
| 16 expect(frame.uri, | |
| 17 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); | |
| 18 expect(frame.line, equals(42)); | |
| 19 expect(frame.column, equals(21)); | |
| 20 expect(frame.member, equals('Foo._bar')); | |
| 21 }); | |
| 22 | |
| 23 test('parses a stack frame without column correctly', () { | |
| 24 var frame = new Frame.parseVM("#1 Foo._bar " | |
| 25 "(file:///home/nweiz/code/stuff.dart:24)"); | |
| 26 expect(frame.uri, | |
| 27 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); | |
| 28 expect(frame.line, equals(24)); | |
| 29 expect(frame.column, null); | |
| 30 expect(frame.member, equals('Foo._bar')); | |
| 31 }); | |
| 32 | |
| 33 test('converts "<anonymous closure>" to "<fn>"', () { | |
| 34 String parsedMember(String member) => | |
| 35 new Frame.parseVM('#0 $member (foo:0:0)').member; | |
| 36 | |
| 37 expect(parsedMember('Foo.<anonymous closure>'), equals('Foo.<fn>')); | |
| 38 expect(parsedMember('<anonymous closure>.<anonymous closure>.bar'), | |
| 39 equals('<fn>.<fn>.bar')); | |
| 40 }); | |
| 41 | |
| 42 test('parses a folded frame correctly', () { | |
| 43 var frame = new Frame.parseVM('...'); | |
| 44 | |
| 45 expect(frame.member, equals('...')); | |
| 46 expect(frame.uri, equals(new Uri())); | |
| 47 expect(frame.line, isNull); | |
| 48 expect(frame.column, isNull); | |
| 49 }); | |
| 50 | |
| 51 test('throws a FormatException for malformed frames', () { | |
| 52 expect(() => new Frame.parseVM(''), throwsFormatException); | |
| 53 expect(() => new Frame.parseVM('#1'), throwsFormatException); | |
| 54 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)'), | |
| 58 throwsFormatException); | |
| 59 expect(() => new Frame.parseVM('Foo (dart:async/future.dart:10:15)'), | |
| 60 throwsFormatException); | |
| 61 }); | |
| 62 }); | |
| 63 | |
| 64 group('.parseV8', () { | |
| 65 test('parses a stack frame correctly', () { | |
| 66 var frame = new Frame.parseV8(" at VW.call\$0 " | |
| 67 "(http://pub.dartlang.org/stuff.dart.js:560:28)"); | |
| 68 expect(frame.uri, | |
| 69 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 70 expect(frame.line, equals(560)); | |
| 71 expect(frame.column, equals(28)); | |
| 72 expect(frame.member, equals('VW.call\$0')); | |
| 73 }); | |
| 74 | |
| 75 test('parses a stack frame with an absolute POSIX path correctly', () { | |
| 76 var frame = new Frame.parseV8(" at VW.call\$0 " | |
| 77 "(/path/to/stuff.dart.js:560:28)"); | |
| 78 expect(frame.uri, equals(Uri.parse("file:///path/to/stuff.dart.js"))); | |
| 79 expect(frame.line, equals(560)); | |
| 80 expect(frame.column, equals(28)); | |
| 81 expect(frame.member, equals('VW.call\$0')); | |
| 82 }); | |
| 83 | |
| 84 test('parses a stack frame with an absolute Windows path correctly', () { | |
| 85 var frame = new Frame.parseV8(" at VW.call\$0 " | |
| 86 r"(C:\path\to\stuff.dart.js:560:28)"); | |
| 87 expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js"))); | |
| 88 expect(frame.line, equals(560)); | |
| 89 expect(frame.column, equals(28)); | |
| 90 expect(frame.member, equals('VW.call\$0')); | |
| 91 }); | |
| 92 | |
| 93 test('parses a stack frame with a Windows UNC path correctly', () { | |
| 94 var frame = new Frame.parseV8(" at VW.call\$0 " | |
| 95 r"(\\mount\path\to\stuff.dart.js:560:28)"); | |
| 96 expect(frame.uri, | |
| 97 equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); | |
| 98 expect(frame.line, equals(560)); | |
| 99 expect(frame.column, equals(28)); | |
| 100 expect(frame.member, equals('VW.call\$0')); | |
| 101 }); | |
| 102 | |
| 103 test('parses a stack frame with a relative POSIX path correctly', () { | |
| 104 var frame = new Frame.parseV8(" at VW.call\$0 " | |
| 105 "(path/to/stuff.dart.js:560:28)"); | |
| 106 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); | |
| 107 expect(frame.line, equals(560)); | |
| 108 expect(frame.column, equals(28)); | |
| 109 expect(frame.member, equals('VW.call\$0')); | |
| 110 }); | |
| 111 | |
| 112 test('parses a stack frame with a relative Windows path correctly', () { | |
| 113 var frame = new Frame.parseV8(" at VW.call\$0 " | |
| 114 r"(path\to\stuff.dart.js:560:28)"); | |
| 115 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); | |
| 116 expect(frame.line, equals(560)); | |
| 117 expect(frame.column, equals(28)); | |
| 118 expect(frame.member, equals('VW.call\$0')); | |
| 119 }); | |
| 120 | |
| 121 test('parses an anonymous stack frame correctly', () { | |
| 122 var frame = new Frame.parseV8( | |
| 123 " at http://pub.dartlang.org/stuff.dart.js:560:28"); | |
| 124 expect(frame.uri, | |
| 125 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 126 expect(frame.line, equals(560)); | |
| 127 expect(frame.column, equals(28)); | |
| 128 expect(frame.member, equals('<fn>')); | |
| 129 }); | |
| 130 | |
| 131 test('parses a stack frame with [as ...] correctly', () { | |
| 132 // Ignore "[as ...]", since other stack trace formats don't support a | |
| 133 // similar construct. | |
| 134 var frame = new Frame.parseV8(" at VW.call\$0 [as call\$4] " | |
| 135 "(http://pub.dartlang.org/stuff.dart.js:560:28)"); | |
| 136 expect(frame.uri, | |
| 137 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 138 expect(frame.line, equals(560)); | |
| 139 expect(frame.column, equals(28)); | |
| 140 expect(frame.member, equals('VW.call\$0')); | |
| 141 }); | |
| 142 | |
| 143 test('parses a basic eval stack frame correctly', () { | |
| 144 var frame = new Frame.parseV8(" at eval (eval at <anonymous> " | |
| 145 "(http://pub.dartlang.org/stuff.dart.js:560:28))"); | |
| 146 expect(frame.uri, | |
| 147 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 148 expect(frame.line, equals(560)); | |
| 149 expect(frame.column, equals(28)); | |
| 150 expect(frame.member, equals('eval')); | |
| 151 }); | |
| 152 | |
| 153 test('parses an IE10 eval stack frame correctly', () { | |
| 154 var frame = new Frame.parseV8(" at eval (eval at Anonymous function " | |
| 155 "(http://pub.dartlang.org/stuff.dart.js:560:28))"); | |
| 156 expect(frame.uri, | |
| 157 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 158 expect(frame.line, equals(560)); | |
| 159 expect(frame.column, equals(28)); | |
| 160 expect(frame.member, equals('eval')); | |
| 161 }); | |
| 162 | |
| 163 test('parses an eval stack frame with inner position info correctly', () { | |
| 164 var frame = new Frame.parseV8(" at eval (eval at <anonymous> " | |
| 165 "(http://pub.dartlang.org/stuff.dart.js:560:28), <anonymous>:3:28)"); | |
| 166 expect(frame.uri, | |
| 167 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 168 expect(frame.line, equals(560)); | |
| 169 expect(frame.column, equals(28)); | |
| 170 expect(frame.member, equals('eval')); | |
| 171 }); | |
| 172 | |
| 173 test('parses a nested eval stack frame correctly', () { | |
| 174 var frame = new Frame.parseV8(" at eval (eval at <anonymous> " | |
| 175 "(eval at sub (http://pub.dartlang.org/stuff.dart.js:560:28)))"); | |
| 176 expect(frame.uri, | |
| 177 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 178 expect(frame.line, equals(560)); | |
| 179 expect(frame.column, equals(28)); | |
| 180 expect(frame.member, equals('eval')); | |
| 181 }); | |
| 182 | |
| 183 test('converts "<anonymous>" to "<fn>"', () { | |
| 184 String parsedMember(String member) => | |
| 185 new Frame.parseV8(' at $member (foo:0:0)').member; | |
| 186 | |
| 187 expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); | |
| 188 expect(parsedMember('<anonymous>.<anonymous>.bar'), | |
| 189 equals('<fn>.<fn>.bar')); | |
| 190 }); | |
| 191 | |
| 192 test('throws a FormatException for malformed frames', () { | |
| 193 expect(() => new Frame.parseV8(''), throwsFormatException); | |
| 194 expect(() => new Frame.parseV8(' at'), throwsFormatException); | |
| 195 expect(() => new Frame.parseV8(' at Foo'), throwsFormatException); | |
| 196 expect(() => new Frame.parseV8(' at Foo (dart:async/future.dart)'), | |
| 197 throwsFormatException); | |
| 198 expect(() => new Frame.parseV8(' at Foo (dart:async/future.dart:10)'), | |
| 199 throwsFormatException); | |
| 200 expect(() => new Frame.parseV8(' at (dart:async/future.dart:10:15)'), | |
| 201 throwsFormatException); | |
| 202 expect(() => new Frame.parseV8('Foo (dart:async/future.dart:10:15)'), | |
| 203 throwsFormatException); | |
| 204 expect(() => new Frame.parseV8(' at dart:async/future.dart'), | |
| 205 throwsFormatException); | |
| 206 expect(() => new Frame.parseV8(' at dart:async/future.dart:10'), | |
| 207 throwsFormatException); | |
| 208 expect(() => new Frame.parseV8('dart:async/future.dart:10:15'), | |
| 209 throwsFormatException); | |
| 210 }); | |
| 211 }); | |
| 212 | |
| 213 group('.parseFirefox/.parseSafari', () { | |
| 214 test('parses a simple stack frame correctly', () { | |
| 215 var frame = new Frame.parseFirefox( | |
| 216 ".VW.call\$0@http://pub.dartlang.org/stuff.dart.js:560"); | |
| 217 expect(frame.uri, | |
| 218 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 219 expect(frame.line, equals(560)); | |
| 220 expect(frame.column, isNull); | |
| 221 expect(frame.member, equals('VW.call\$0')); | |
| 222 }); | |
| 223 | |
| 224 test('parses a stack frame with an absolute POSIX path correctly', () { | |
| 225 var frame = new Frame.parseFirefox( | |
| 226 ".VW.call\$0@/path/to/stuff.dart.js:560"); | |
| 227 expect(frame.uri, equals(Uri.parse("file:///path/to/stuff.dart.js"))); | |
| 228 expect(frame.line, equals(560)); | |
| 229 expect(frame.column, isNull); | |
| 230 expect(frame.member, equals('VW.call\$0')); | |
| 231 }); | |
| 232 | |
| 233 test('parses a stack frame with an absolute Windows path correctly', () { | |
| 234 var frame = new Frame.parseFirefox( | |
| 235 r".VW.call$0@C:\path\to\stuff.dart.js:560"); | |
| 236 expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js"))); | |
| 237 expect(frame.line, equals(560)); | |
| 238 expect(frame.column, isNull); | |
| 239 expect(frame.member, equals('VW.call\$0')); | |
| 240 }); | |
| 241 | |
| 242 test('parses a stack frame with a Windows UNC path correctly', () { | |
| 243 var frame = new Frame.parseFirefox( | |
| 244 r".VW.call$0@\\mount\path\to\stuff.dart.js:560"); | |
| 245 expect(frame.uri, | |
| 246 equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); | |
| 247 expect(frame.line, equals(560)); | |
| 248 expect(frame.column, isNull); | |
| 249 expect(frame.member, equals('VW.call\$0')); | |
| 250 }); | |
| 251 | |
| 252 test('parses a stack frame with a relative POSIX path correctly', () { | |
| 253 var frame = new Frame.parseFirefox( | |
| 254 ".VW.call\$0@path/to/stuff.dart.js:560"); | |
| 255 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); | |
| 256 expect(frame.line, equals(560)); | |
| 257 expect(frame.column, isNull); | |
| 258 expect(frame.member, equals('VW.call\$0')); | |
| 259 }); | |
| 260 | |
| 261 test('parses a stack frame with a relative Windows path correctly', () { | |
| 262 var frame = new Frame.parseFirefox( | |
| 263 r".VW.call$0@path\to\stuff.dart.js:560"); | |
| 264 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); | |
| 265 expect(frame.line, equals(560)); | |
| 266 expect(frame.column, isNull); | |
| 267 expect(frame.member, equals('VW.call\$0')); | |
| 268 }); | |
| 269 | |
| 270 test('parses a simple anonymous stack frame correctly', () { | |
| 271 var frame = new Frame.parseFirefox( | |
| 272 "@http://pub.dartlang.org/stuff.dart.js:560"); | |
| 273 expect(frame.uri, | |
| 274 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 275 expect(frame.line, equals(560)); | |
| 276 expect(frame.column, isNull); | |
| 277 expect(frame.member, equals("<fn>")); | |
| 278 }); | |
| 279 | |
| 280 test('parses a nested anonymous stack frame correctly', () { | |
| 281 var frame = new Frame.parseFirefox( | |
| 282 ".foo/<@http://pub.dartlang.org/stuff.dart.js:560"); | |
| 283 expect(frame.uri, | |
| 284 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 285 expect(frame.line, equals(560)); | |
| 286 expect(frame.column, isNull); | |
| 287 expect(frame.member, equals("foo.<fn>")); | |
| 288 | |
| 289 frame = new Frame.parseFirefox( | |
| 290 ".foo/@http://pub.dartlang.org/stuff.dart.js:560"); | |
| 291 expect(frame.uri, | |
| 292 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 293 expect(frame.line, equals(560)); | |
| 294 expect(frame.column, isNull); | |
| 295 expect(frame.member, equals("foo.<fn>")); | |
| 296 }); | |
| 297 | |
| 298 test('parses a named nested anonymous stack frame correctly', () { | |
| 299 var frame = new Frame.parseFirefox( | |
| 300 ".foo/.name<@http://pub.dartlang.org/stuff.dart.js:560"); | |
| 301 expect(frame.uri, | |
| 302 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 303 expect(frame.line, equals(560)); | |
| 304 expect(frame.column, isNull); | |
| 305 expect(frame.member, equals("foo.<fn>")); | |
| 306 | |
| 307 frame = new Frame.parseFirefox( | |
| 308 ".foo/.name@http://pub.dartlang.org/stuff.dart.js:560"); | |
| 309 expect(frame.uri, | |
| 310 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 311 expect(frame.line, equals(560)); | |
| 312 expect(frame.column, isNull); | |
| 313 expect(frame.member, equals("foo.<fn>")); | |
| 314 }); | |
| 315 | |
| 316 test('parses a stack frame with parameters correctly', () { | |
| 317 var frame = new Frame.parseFirefox( | |
| 318 '.foo(12, "@)()/<")@http://pub.dartlang.org/stuff.dart.js:560'); | |
| 319 expect(frame.uri, | |
| 320 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 321 expect(frame.line, equals(560)); | |
| 322 expect(frame.column, isNull); | |
| 323 expect(frame.member, equals("foo")); | |
| 324 }); | |
| 325 | |
| 326 test('parses a nested anonymous stack frame with parameters correctly', () { | |
| 327 var frame = new Frame.parseFirefox( | |
| 328 '.foo(12, "@)()/<")/.fn<@' | |
| 329 'http://pub.dartlang.org/stuff.dart.js:560'); | |
| 330 expect(frame.uri, | |
| 331 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 332 expect(frame.line, equals(560)); | |
| 333 expect(frame.column, isNull); | |
| 334 expect(frame.member, equals("foo.<fn>")); | |
| 335 }); | |
| 336 | |
| 337 test('parses a deeply-nested anonymous stack frame with parameters ' | |
| 338 'correctly', () { | |
| 339 var frame = new Frame.parseFirefox( | |
| 340 '.convertDartClosureToJS/\$function</<@' | |
| 341 'http://pub.dartlang.org/stuff.dart.js:560'); | |
| 342 expect(frame.uri, | |
| 343 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | |
| 344 expect(frame.line, equals(560)); | |
| 345 expect(frame.column, isNull); | |
| 346 expect(frame.member, equals("convertDartClosureToJS.<fn>.<fn>")); | |
| 347 }); | |
| 348 | |
| 349 test('throws a FormatException for malformed frames', () { | |
| 350 expect(() => new Frame.parseFirefox(''), throwsFormatException); | |
| 351 expect(() => new Frame.parseFirefox('.foo'), throwsFormatException); | |
| 352 expect(() => new Frame.parseFirefox('.foo@dart:async/future.dart'), | |
| 353 throwsFormatException); | |
| 354 expect(() => new Frame.parseFirefox('.foo(@dart:async/future.dart:10'), | |
| 355 throwsFormatException); | |
| 356 expect(() => new Frame.parseFirefox('@dart:async/future.dart'), | |
| 357 throwsFormatException); | |
| 358 }); | |
| 359 | |
| 360 test('parses a simple stack frame correctly', () { | |
| 361 var frame = new Frame.parseFirefox( | |
| 362 "foo\$bar@http://dartlang.org/foo/bar.dart:10:11"); | |
| 363 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 364 expect(frame.line, equals(10)); | |
| 365 expect(frame.column, equals(11)); | |
| 366 expect(frame.member, equals('foo\$bar')); | |
| 367 }); | |
| 368 | |
| 369 test('parses an anonymous stack frame correctly', () { | |
| 370 var frame = new Frame.parseFirefox( | |
| 371 "http://dartlang.org/foo/bar.dart:10:11"); | |
| 372 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 373 expect(frame.line, equals(10)); | |
| 374 expect(frame.column, equals(11)); | |
| 375 expect(frame.member, equals('<fn>')); | |
| 376 }); | |
| 377 | |
| 378 test('parses a stack frame with no line correctly', () { | |
| 379 var frame = new Frame.parseFirefox( | |
| 380 "foo\$bar@http://dartlang.org/foo/bar.dart::11"); | |
| 381 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 382 expect(frame.line, isNull); | |
| 383 expect(frame.column, equals(11)); | |
| 384 expect(frame.member, equals('foo\$bar')); | |
| 385 }); | |
| 386 | |
| 387 test('parses a stack frame with no column correctly', () { | |
| 388 var frame = new Frame.parseFirefox( | |
| 389 "foo\$bar@http://dartlang.org/foo/bar.dart:10:"); | |
| 390 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 391 expect(frame.line, equals(10)); | |
| 392 expect(frame.column, isNull); | |
| 393 expect(frame.member, equals('foo\$bar')); | |
| 394 }); | |
| 395 | |
| 396 test('parses a stack frame with no line or column correctly', () { | |
| 397 var frame = new Frame.parseFirefox( | |
| 398 "foo\$bar@http://dartlang.org/foo/bar.dart:10:11"); | |
| 399 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 400 expect(frame.line, equals(10)); | |
| 401 expect(frame.column, equals(11)); | |
| 402 expect(frame.member, equals('foo\$bar')); | |
| 403 }); | |
| 404 }); | |
| 405 | |
| 406 group('.parseFriendly', () { | |
| 407 test('parses a simple stack frame correctly', () { | |
| 408 var frame = new Frame.parseFriendly( | |
| 409 "http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar"); | |
| 410 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 411 expect(frame.line, equals(10)); | |
| 412 expect(frame.column, equals(11)); | |
| 413 expect(frame.member, equals('Foo.<fn>.bar')); | |
| 414 }); | |
| 415 | |
| 416 test('parses a stack frame with no line or column correctly', () { | |
| 417 var frame = new Frame.parseFriendly( | |
| 418 "http://dartlang.org/foo/bar.dart Foo.<fn>.bar"); | |
| 419 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 420 expect(frame.line, isNull); | |
| 421 expect(frame.column, isNull); | |
| 422 expect(frame.member, equals('Foo.<fn>.bar')); | |
| 423 }); | |
| 424 | |
| 425 test('parses a stack frame with no line correctly', () { | |
| 426 var frame = new Frame.parseFriendly( | |
| 427 "http://dartlang.org/foo/bar.dart 10 Foo.<fn>.bar"); | |
| 428 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | |
| 429 expect(frame.line, equals(10)); | |
| 430 expect(frame.column, isNull); | |
| 431 expect(frame.member, equals('Foo.<fn>.bar')); | |
| 432 }); | |
| 433 | |
| 434 test('parses a stack frame with a relative path correctly', () { | |
| 435 var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar"); | |
| 436 expect(frame.uri, equals( | |
| 437 path.toUri(path.absolute(path.join('foo', 'bar.dart'))))); | |
| 438 expect(frame.line, equals(10)); | |
| 439 expect(frame.column, equals(11)); | |
| 440 expect(frame.member, equals('Foo.<fn>.bar')); | |
| 441 }); | |
| 442 | |
| 443 test('throws a FormatException for malformed frames', () { | |
| 444 expect(() => new Frame.parseFriendly(''), throwsFormatException); | |
| 445 expect(() => new Frame.parseFriendly('foo/bar.dart'), | |
| 446 throwsFormatException); | |
| 447 expect(() => new Frame.parseFriendly('foo/bar.dart 10:11'), | |
| 448 throwsFormatException); | |
| 449 }); | |
| 450 }); | |
| 451 | |
| 452 test('only considers dart URIs to be core', () { | |
| 453 bool isCore(String library) => | |
| 454 new Frame.parseVM('#0 Foo ($library:0:0)').isCore; | |
| 455 | |
| 456 expect(isCore('dart:core'), isTrue); | |
| 457 expect(isCore('dart:async'), isTrue); | |
| 458 expect(isCore('dart:core/uri.dart'), isTrue); | |
| 459 expect(isCore('dart:async/future.dart'), isTrue); | |
| 460 expect(isCore('bart:core'), isFalse); | |
| 461 expect(isCore('sdart:core'), isFalse); | |
| 462 expect(isCore('darty:core'), isFalse); | |
| 463 expect(isCore('bart:core/uri.dart'), isFalse); | |
| 464 }); | |
| 465 | |
| 466 group('.library', () { | |
| 467 test('returns the URI string for non-file URIs', () { | |
| 468 expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').library, | |
| 469 equals('dart:async/future.dart')); | |
| 470 expect(new Frame.parseVM('#0 Foo ' | |
| 471 '(http://dartlang.org/stuff/thing.dart:0:0)').library, | |
| 472 equals('http://dartlang.org/stuff/thing.dart')); | |
| 473 }); | |
| 474 | |
| 475 test('returns the relative path for file URIs', () { | |
| 476 expect(new Frame.parseVM('#0 Foo (foo/bar.dart:0:0)').library, | |
| 477 equals(path.join('foo', 'bar.dart'))); | |
| 478 }); | |
| 479 }); | |
| 480 | |
| 481 group('.location', () { | |
| 482 test('returns the library and line/column numbers for non-core ' | |
| 483 'libraries', () { | |
| 484 expect(new Frame.parseVM('#0 Foo ' | |
| 485 '(http://dartlang.org/thing.dart:5:10)').location, | |
| 486 equals('http://dartlang.org/thing.dart 5:10')); | |
| 487 expect(new Frame.parseVM('#0 Foo (foo/bar.dart:1:2)').location, | |
| 488 equals('${path.join('foo', 'bar.dart')} 1:2')); | |
| 489 }); | |
| 490 }); | |
| 491 | |
| 492 group('.package', () { | |
| 493 test('returns null for non-package URIs', () { | |
| 494 expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').package, | |
| 495 isNull); | |
| 496 expect(new Frame.parseVM('#0 Foo ' | |
| 497 '(http://dartlang.org/stuff/thing.dart:0:0)').package, | |
| 498 isNull); | |
| 499 }); | |
| 500 | |
| 501 test('returns the package name for package: URIs', () { | |
| 502 expect(new Frame.parseVM('#0 Foo (package:foo/foo.dart:0:0)').package, | |
| 503 equals('foo')); | |
| 504 expect(new Frame.parseVM('#0 Foo (package:foo/zap/bar.dart:0:0)').package, | |
| 505 equals('foo')); | |
| 506 }); | |
| 507 }); | |
| 508 | |
| 509 group('.toString()', () { | |
| 510 test('returns the library and line/column numbers for non-core ' | |
| 511 'libraries', () { | |
| 512 expect(new Frame.parseVM('#0 Foo (http://dartlang.org/thing.dart:5:10)') | |
| 513 .toString(), | |
| 514 equals('http://dartlang.org/thing.dart 5:10 in Foo')); | |
| 515 }); | |
| 516 | |
| 517 test('converts "<anonymous closure>" to "<fn>"', () { | |
| 518 expect(new Frame.parseVM('#0 Foo.<anonymous closure> ' | |
| 519 '(dart:core/uri.dart:5:10)').toString(), | |
| 520 equals('dart:core/uri.dart 5:10 in Foo.<fn>')); | |
| 521 }); | |
| 522 | |
| 523 test('prints a frame without a column correctly', () { | |
| 524 expect(new Frame.parseVM('#0 Foo (dart:core/uri.dart:5)').toString(), | |
| 525 equals('dart:core/uri.dart 5 in Foo')); | |
| 526 }); | |
| 527 | |
| 528 test('prints relative paths as relative', () { | |
| 529 var relative = path.normalize('relative/path/to/foo.dart'); | |
| 530 expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), | |
| 531 equals('$relative 5:10 in Foo')); | |
| 532 }); | |
| 533 }); | |
| 534 } | |
| OLD | NEW |