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; | |
6 | |
7 import 'package:path/path.dart' as path; | 5 import 'package:path/path.dart' as path; |
8 import 'package:stack_trace/stack_trace.dart'; | 6 import 'package:stack_trace/stack_trace.dart'; |
9 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
10 | 8 |
11 void main() { | 9 void main() { |
12 group('.parseVM', () { | 10 group('.parseVM', () { |
13 test('parses a stack frame with column correctly', () { | 11 test('parses a stack frame with column correctly', () { |
14 var frame = new Frame.parseVM("#1 Foo._bar " | 12 var frame = new Frame.parseVM("#1 Foo._bar " |
15 "(file:///home/nweiz/code/stuff.dart:42:21)"); | 13 "(file:///home/nweiz/code/stuff.dart:42:21)"); |
16 expect(frame.uri, | 14 expect( |
17 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); | 15 frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); |
18 expect(frame.line, equals(42)); | 16 expect(frame.line, equals(42)); |
19 expect(frame.column, equals(21)); | 17 expect(frame.column, equals(21)); |
20 expect(frame.member, equals('Foo._bar')); | 18 expect(frame.member, equals('Foo._bar')); |
21 }); | 19 }); |
22 | 20 |
23 test('parses a stack frame without column correctly', () { | 21 test('parses a stack frame without column correctly', () { |
24 var frame = new Frame.parseVM("#1 Foo._bar " | 22 var frame = new Frame.parseVM("#1 Foo._bar " |
25 "(file:///home/nweiz/code/stuff.dart:24)"); | 23 "(file:///home/nweiz/code/stuff.dart:24)"); |
26 expect(frame.uri, | 24 expect( |
27 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); | 25 frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); |
28 expect(frame.line, equals(24)); | 26 expect(frame.line, equals(24)); |
29 expect(frame.column, null); | 27 expect(frame.column, null); |
30 expect(frame.member, equals('Foo._bar')); | 28 expect(frame.member, equals('Foo._bar')); |
31 }); | 29 }); |
32 | 30 |
33 // This can happen with async stack traces. See issue 22009. | 31 // This can happen with async stack traces. See issue 22009. |
34 test('parses a stack frame without line or column correctly', () { | 32 test('parses a stack frame without line or column correctly', () { |
35 var frame = new Frame.parseVM("#1 Foo._bar " | 33 var frame = new Frame.parseVM("#1 Foo._bar " |
36 "(file:///home/nweiz/code/stuff.dart)"); | 34 "(file:///home/nweiz/code/stuff.dart)"); |
37 expect(frame.uri, | 35 expect( |
38 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); | 36 frame.uri, equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); |
39 expect(frame.line, isNull); | 37 expect(frame.line, isNull); |
40 expect(frame.column, isNull); | 38 expect(frame.column, isNull); |
41 expect(frame.member, equals('Foo._bar')); | 39 expect(frame.member, equals('Foo._bar')); |
42 }); | 40 }); |
43 | 41 |
44 test('converts "<anonymous closure>" to "<fn>"', () { | 42 test('converts "<anonymous closure>" to "<fn>"', () { |
45 String parsedMember(String member) => | 43 String parsedMember(String member) => |
46 new Frame.parseVM('#0 $member (foo:0:0)').member; | 44 new Frame.parseVM('#0 $member (foo:0:0)').member; |
47 | 45 |
48 expect(parsedMember('Foo.<anonymous closure>'), equals('Foo.<fn>')); | 46 expect(parsedMember('Foo.<anonymous closure>'), equals('Foo.<fn>')); |
49 expect(parsedMember('<anonymous closure>.<anonymous closure>.bar'), | 47 expect(parsedMember('<anonymous closure>.<anonymous closure>.bar'), |
50 equals('<fn>.<fn>.bar')); | 48 equals('<fn>.<fn>.bar')); |
51 }); | 49 }); |
52 | 50 |
53 test('converts "<<anonymous closure>_async_body>" to "<async>"', () { | 51 test('converts "<<anonymous closure>_async_body>" to "<async>"', () { |
54 var frame = new Frame.parseVM( | 52 var frame = new Frame.parseVM( |
55 '#0 Foo.<<anonymous closure>_async_body> (foo:0:0)'); | 53 '#0 Foo.<<anonymous closure>_async_body> (foo:0:0)'); |
56 expect(frame.member, equals('Foo.<async>')); | 54 expect(frame.member, equals('Foo.<async>')); |
57 }); | 55 }); |
58 | 56 |
59 test('converts "<function_name_async_body>" to "<async>"', () { | 57 test('converts "<function_name_async_body>" to "<async>"', () { |
60 var frame = new Frame.parseVM( | 58 var frame = |
61 '#0 Foo.<function_name_async_body> (foo:0:0)'); | 59 new Frame.parseVM('#0 Foo.<function_name_async_body> (foo:0:0)'); |
62 expect(frame.member, equals('Foo.<async>')); | 60 expect(frame.member, equals('Foo.<async>')); |
63 }); | 61 }); |
64 | 62 |
65 test('parses a folded frame correctly', () { | 63 test('parses a folded frame correctly', () { |
66 var frame = new Frame.parseVM('...'); | 64 var frame = new Frame.parseVM('...'); |
67 | 65 |
68 expect(frame.member, equals('...')); | 66 expect(frame.member, equals('...')); |
69 expect(frame.uri, equals(new Uri())); | 67 expect(frame.uri, equals(new Uri())); |
70 expect(frame.line, isNull); | 68 expect(frame.line, isNull); |
71 expect(frame.column, isNull); | 69 expect(frame.column, isNull); |
72 }); | 70 }); |
| 71 }); |
73 | 72 |
| 73 group('.parseV8', () { |
74 test('returns an UnparsedFrame for malformed frames', () { | 74 test('returns an UnparsedFrame for malformed frames', () { |
75 expectIsUnparsed((text) => new Frame.parseV8(text), ''); | 75 expectIsUnparsed((text) => new Frame.parseV8(text), ''); |
76 expectIsUnparsed((text) => new Frame.parseV8(text), '#1'); | 76 expectIsUnparsed((text) => new Frame.parseV8(text), '#1'); |
77 expectIsUnparsed((text) => new Frame.parseV8(text), '#1 Foo'); | 77 expectIsUnparsed((text) => new Frame.parseV8(text), '#1 Foo'); |
78 expectIsUnparsed((text) => new Frame.parseV8(text), | 78 expectIsUnparsed((text) => new Frame.parseV8(text), |
79 '#1 (dart:async/future.dart:10:15)'); | 79 '#1 (dart:async/future.dart:10:15)'); |
80 expectIsUnparsed((text) => new Frame.parseV8(text), | 80 expectIsUnparsed((text) => new Frame.parseV8(text), |
81 'Foo (dart:async/future.dart:10:15)'); | 81 'Foo (dart:async/future.dart:10:15)'); |
82 }); | 82 }); |
83 }); | |
84 | 83 |
85 group('.parseV8', () { | |
86 test('parses a stack frame correctly', () { | 84 test('parses a stack frame correctly', () { |
87 var frame = new Frame.parseV8(" at VW.call\$0 " | 85 var frame = new Frame.parseV8(" at VW.call\$0 " |
88 "(http://pub.dartlang.org/stuff.dart.js:560:28)"); | 86 "(http://pub.dartlang.org/stuff.dart.js:560:28)"); |
89 expect(frame.uri, | 87 expect(frame.uri, |
90 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 88 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
91 expect(frame.line, equals(560)); | 89 expect(frame.line, equals(560)); |
92 expect(frame.column, equals(28)); | 90 expect(frame.column, equals(28)); |
93 expect(frame.member, equals('VW.call\$0')); | 91 expect(frame.member, equals('VW.call\$0')); |
94 }); | 92 }); |
95 | 93 |
(...skipping 11 matching lines...) Expand all Loading... |
107 r"(C:\path\to\stuff.dart.js:560:28)"); | 105 r"(C:\path\to\stuff.dart.js:560:28)"); |
108 expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js"))); | 106 expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js"))); |
109 expect(frame.line, equals(560)); | 107 expect(frame.line, equals(560)); |
110 expect(frame.column, equals(28)); | 108 expect(frame.column, equals(28)); |
111 expect(frame.member, equals('VW.call\$0')); | 109 expect(frame.member, equals('VW.call\$0')); |
112 }); | 110 }); |
113 | 111 |
114 test('parses a stack frame with a Windows UNC path correctly', () { | 112 test('parses a stack frame with a Windows UNC path correctly', () { |
115 var frame = new Frame.parseV8(" at VW.call\$0 " | 113 var frame = new Frame.parseV8(" at VW.call\$0 " |
116 r"(\\mount\path\to\stuff.dart.js:560:28)"); | 114 r"(\\mount\path\to\stuff.dart.js:560:28)"); |
117 expect(frame.uri, | 115 expect( |
118 equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); | 116 frame.uri, equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); |
119 expect(frame.line, equals(560)); | 117 expect(frame.line, equals(560)); |
120 expect(frame.column, equals(28)); | 118 expect(frame.column, equals(28)); |
121 expect(frame.member, equals('VW.call\$0')); | 119 expect(frame.member, equals('VW.call\$0')); |
122 }); | 120 }); |
123 | 121 |
124 test('parses a stack frame with a relative POSIX path correctly', () { | 122 test('parses a stack frame with a relative POSIX path correctly', () { |
125 var frame = new Frame.parseV8(" at VW.call\$0 " | 123 var frame = new Frame.parseV8(" at VW.call\$0 " |
126 "(path/to/stuff.dart.js:560:28)"); | 124 "(path/to/stuff.dart.js:560:28)"); |
127 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); | 125 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); |
128 expect(frame.line, equals(560)); | 126 expect(frame.line, equals(560)); |
(...skipping 14 matching lines...) Expand all Loading... |
143 var frame = new Frame.parseV8( | 141 var frame = new Frame.parseV8( |
144 " at http://pub.dartlang.org/stuff.dart.js:560:28"); | 142 " at http://pub.dartlang.org/stuff.dart.js:560:28"); |
145 expect(frame.uri, | 143 expect(frame.uri, |
146 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 144 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
147 expect(frame.line, equals(560)); | 145 expect(frame.line, equals(560)); |
148 expect(frame.column, equals(28)); | 146 expect(frame.column, equals(28)); |
149 expect(frame.member, equals('<fn>')); | 147 expect(frame.member, equals('<fn>')); |
150 }); | 148 }); |
151 | 149 |
152 test('parses a native stack frame correctly', () { | 150 test('parses a native stack frame correctly', () { |
153 var frame = new Frame.parseV8( | 151 var frame = new Frame.parseV8(" at Object.stringify (native)"); |
154 " at Object.stringify (native)"); | |
155 expect(frame.uri, Uri.parse('native')); | 152 expect(frame.uri, Uri.parse('native')); |
156 expect(frame.line, isNull); | 153 expect(frame.line, isNull); |
157 expect(frame.column, isNull); | 154 expect(frame.column, isNull); |
158 expect(frame.member, equals('Object.stringify')); | 155 expect(frame.member, equals('Object.stringify')); |
159 }); | 156 }); |
160 | 157 |
161 test('parses a stack frame with [as ...] correctly', () { | 158 test('parses a stack frame with [as ...] correctly', () { |
162 // Ignore "[as ...]", since other stack trace formats don't support a | 159 // Ignore "[as ...]", since other stack trace formats don't support a |
163 // similar construct. | 160 // similar construct. |
164 var frame = new Frame.parseV8(" at VW.call\$0 [as call\$4] " | 161 var frame = new Frame.parseV8(" at VW.call\$0 [as call\$4] " |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 expect(frame.line, equals(560)); | 205 expect(frame.line, equals(560)); |
209 expect(frame.column, equals(28)); | 206 expect(frame.column, equals(28)); |
210 expect(frame.member, equals('eval')); | 207 expect(frame.member, equals('eval')); |
211 }); | 208 }); |
212 | 209 |
213 test('converts "<anonymous>" to "<fn>"', () { | 210 test('converts "<anonymous>" to "<fn>"', () { |
214 String parsedMember(String member) => | 211 String parsedMember(String member) => |
215 new Frame.parseV8(' at $member (foo:0:0)').member; | 212 new Frame.parseV8(' at $member (foo:0:0)').member; |
216 | 213 |
217 expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); | 214 expect(parsedMember('Foo.<anonymous>'), equals('Foo.<fn>')); |
218 expect(parsedMember('<anonymous>.<anonymous>.bar'), | 215 expect( |
219 equals('<fn>.<fn>.bar')); | 216 parsedMember('<anonymous>.<anonymous>.bar'), equals('<fn>.<fn>.bar')); |
220 }); | 217 }); |
221 | 218 |
222 test('returns an UnparsedFrame for malformed frames', () { | 219 test('returns an UnparsedFrame for malformed frames', () { |
223 expectIsUnparsed((text) => new Frame.parseV8(text), ''); | 220 expectIsUnparsed((text) => new Frame.parseV8(text), ''); |
224 expectIsUnparsed((text) => new Frame.parseV8(text), ' at'); | 221 expectIsUnparsed((text) => new Frame.parseV8(text), ' at'); |
225 expectIsUnparsed((text) => new Frame.parseV8(text), ' at Foo'); | 222 expectIsUnparsed((text) => new Frame.parseV8(text), ' at Foo'); |
226 expectIsUnparsed((text) => new Frame.parseV8(text), | 223 expectIsUnparsed((text) => new Frame.parseV8(text), |
227 ' at Foo (dart:async/future.dart)'); | 224 ' at Foo (dart:async/future.dart)'); |
228 expectIsUnparsed((text) => new Frame.parseV8(text), | 225 expectIsUnparsed((text) => new Frame.parseV8(text), |
229 ' at (dart:async/future.dart:10:15)'); | 226 ' at (dart:async/future.dart:10:15)'); |
230 expectIsUnparsed((text) => new Frame.parseV8(text), | 227 expectIsUnparsed((text) => new Frame.parseV8(text), |
231 'Foo (dart:async/future.dart:10:15)'); | 228 'Foo (dart:async/future.dart:10:15)'); |
232 expectIsUnparsed((text) => new Frame.parseV8(text), | 229 expectIsUnparsed( |
233 ' at dart:async/future.dart'); | 230 (text) => new Frame.parseV8(text), ' at dart:async/future.dart'); |
234 expectIsUnparsed((text) => new Frame.parseV8(text), | 231 expectIsUnparsed((text) => new Frame.parseV8(text), |
235 ' at dart:async/future.dart:10'); | 232 ' at dart:async/future.dart:10'); |
236 expectIsUnparsed((text) => new Frame.parseV8(text), | 233 expectIsUnparsed( |
237 'dart:async/future.dart:10:15'); | 234 (text) => new Frame.parseV8(text), 'dart:async/future.dart:10:15'); |
238 }); | 235 }); |
239 }); | 236 }); |
240 | 237 |
241 group('.parseFirefox/.parseSafari', () { | 238 group('.parseFirefox/.parseSafari', () { |
242 test('parses a simple stack frame correctly', () { | 239 test('parses a simple stack frame correctly', () { |
243 var frame = new Frame.parseFirefox( | 240 var frame = new Frame.parseFirefox( |
244 ".VW.call\$0@http://pub.dartlang.org/stuff.dart.js:560"); | 241 ".VW.call\$0@http://pub.dartlang.org/stuff.dart.js:560"); |
245 expect(frame.uri, | 242 expect(frame.uri, |
246 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 243 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
247 expect(frame.line, equals(560)); | 244 expect(frame.line, equals(560)); |
248 expect(frame.column, isNull); | 245 expect(frame.column, isNull); |
249 expect(frame.member, equals('VW.call\$0')); | 246 expect(frame.member, equals('VW.call\$0')); |
250 }); | 247 }); |
251 | 248 |
252 test('parses a stack frame with an absolute POSIX path correctly', () { | 249 test('parses a stack frame with an absolute POSIX path correctly', () { |
253 var frame = new Frame.parseFirefox( | 250 var frame = |
254 ".VW.call\$0@/path/to/stuff.dart.js:560"); | 251 new Frame.parseFirefox(".VW.call\$0@/path/to/stuff.dart.js:560"); |
255 expect(frame.uri, equals(Uri.parse("file:///path/to/stuff.dart.js"))); | 252 expect(frame.uri, equals(Uri.parse("file:///path/to/stuff.dart.js"))); |
256 expect(frame.line, equals(560)); | 253 expect(frame.line, equals(560)); |
257 expect(frame.column, isNull); | 254 expect(frame.column, isNull); |
258 expect(frame.member, equals('VW.call\$0')); | 255 expect(frame.member, equals('VW.call\$0')); |
259 }); | 256 }); |
260 | 257 |
261 test('parses a stack frame with an absolute Windows path correctly', () { | 258 test('parses a stack frame with an absolute Windows path correctly', () { |
262 var frame = new Frame.parseFirefox( | 259 var frame = |
263 r".VW.call$0@C:\path\to\stuff.dart.js:560"); | 260 new Frame.parseFirefox(r".VW.call$0@C:\path\to\stuff.dart.js:560"); |
264 expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js"))); | 261 expect(frame.uri, equals(Uri.parse("file:///C:/path/to/stuff.dart.js"))); |
265 expect(frame.line, equals(560)); | 262 expect(frame.line, equals(560)); |
266 expect(frame.column, isNull); | 263 expect(frame.column, isNull); |
267 expect(frame.member, equals('VW.call\$0')); | 264 expect(frame.member, equals('VW.call\$0')); |
268 }); | 265 }); |
269 | 266 |
270 test('parses a stack frame with a Windows UNC path correctly', () { | 267 test('parses a stack frame with a Windows UNC path correctly', () { |
271 var frame = new Frame.parseFirefox( | 268 var frame = new Frame.parseFirefox( |
272 r".VW.call$0@\\mount\path\to\stuff.dart.js:560"); | 269 r".VW.call$0@\\mount\path\to\stuff.dart.js:560"); |
273 expect(frame.uri, | 270 expect( |
274 equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); | 271 frame.uri, equals(Uri.parse("file://mount/path/to/stuff.dart.js"))); |
275 expect(frame.line, equals(560)); | 272 expect(frame.line, equals(560)); |
276 expect(frame.column, isNull); | 273 expect(frame.column, isNull); |
277 expect(frame.member, equals('VW.call\$0')); | 274 expect(frame.member, equals('VW.call\$0')); |
278 }); | 275 }); |
279 | 276 |
280 test('parses a stack frame with a relative POSIX path correctly', () { | 277 test('parses a stack frame with a relative POSIX path correctly', () { |
281 var frame = new Frame.parseFirefox( | 278 var frame = |
282 ".VW.call\$0@path/to/stuff.dart.js:560"); | 279 new Frame.parseFirefox(".VW.call\$0@path/to/stuff.dart.js:560"); |
283 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); | 280 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); |
284 expect(frame.line, equals(560)); | 281 expect(frame.line, equals(560)); |
285 expect(frame.column, isNull); | 282 expect(frame.column, isNull); |
286 expect(frame.member, equals('VW.call\$0')); | 283 expect(frame.member, equals('VW.call\$0')); |
287 }); | 284 }); |
288 | 285 |
289 test('parses a stack frame with a relative Windows path correctly', () { | 286 test('parses a stack frame with a relative Windows path correctly', () { |
290 var frame = new Frame.parseFirefox( | 287 var frame = |
291 r".VW.call$0@path\to\stuff.dart.js:560"); | 288 new Frame.parseFirefox(r".VW.call$0@path\to\stuff.dart.js:560"); |
292 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); | 289 expect(frame.uri, equals(Uri.parse("path/to/stuff.dart.js"))); |
293 expect(frame.line, equals(560)); | 290 expect(frame.line, equals(560)); |
294 expect(frame.column, isNull); | 291 expect(frame.column, isNull); |
295 expect(frame.member, equals('VW.call\$0')); | 292 expect(frame.member, equals('VW.call\$0')); |
296 }); | 293 }); |
297 | 294 |
298 test('parses a simple anonymous stack frame correctly', () { | 295 test('parses a simple anonymous stack frame correctly', () { |
299 var frame = new Frame.parseFirefox( | 296 var frame = |
300 "@http://pub.dartlang.org/stuff.dart.js:560"); | 297 new Frame.parseFirefox("@http://pub.dartlang.org/stuff.dart.js:560"); |
301 expect(frame.uri, | 298 expect(frame.uri, |
302 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 299 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
303 expect(frame.line, equals(560)); | 300 expect(frame.line, equals(560)); |
304 expect(frame.column, isNull); | 301 expect(frame.column, isNull); |
305 expect(frame.member, equals("<fn>")); | 302 expect(frame.member, equals("<fn>")); |
306 }); | 303 }); |
307 | 304 |
308 test('parses a nested anonymous stack frame correctly', () { | 305 test('parses a nested anonymous stack frame correctly', () { |
309 var frame = new Frame.parseFirefox( | 306 var frame = new Frame.parseFirefox( |
310 ".foo/<@http://pub.dartlang.org/stuff.dart.js:560"); | 307 ".foo/<@http://pub.dartlang.org/stuff.dart.js:560"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 var frame = new Frame.parseFirefox( | 342 var frame = new Frame.parseFirefox( |
346 '.foo(12, "@)()/<")@http://pub.dartlang.org/stuff.dart.js:560'); | 343 '.foo(12, "@)()/<")@http://pub.dartlang.org/stuff.dart.js:560'); |
347 expect(frame.uri, | 344 expect(frame.uri, |
348 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 345 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
349 expect(frame.line, equals(560)); | 346 expect(frame.line, equals(560)); |
350 expect(frame.column, isNull); | 347 expect(frame.column, isNull); |
351 expect(frame.member, equals("foo")); | 348 expect(frame.member, equals("foo")); |
352 }); | 349 }); |
353 | 350 |
354 test('parses a nested anonymous stack frame with parameters correctly', () { | 351 test('parses a nested anonymous stack frame with parameters correctly', () { |
355 var frame = new Frame.parseFirefox( | 352 var frame = new Frame.parseFirefox('.foo(12, "@)()/<")/.fn<@' |
356 '.foo(12, "@)()/<")/.fn<@' | |
357 'http://pub.dartlang.org/stuff.dart.js:560'); | 353 'http://pub.dartlang.org/stuff.dart.js:560'); |
358 expect(frame.uri, | 354 expect(frame.uri, |
359 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 355 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
360 expect(frame.line, equals(560)); | 356 expect(frame.line, equals(560)); |
361 expect(frame.column, isNull); | 357 expect(frame.column, isNull); |
362 expect(frame.member, equals("foo.<fn>")); | 358 expect(frame.member, equals("foo.<fn>")); |
363 }); | 359 }); |
364 | 360 |
365 test('parses a deeply-nested anonymous stack frame with parameters ' | 361 test( |
| 362 'parses a deeply-nested anonymous stack frame with parameters ' |
366 'correctly', () { | 363 'correctly', () { |
367 var frame = new Frame.parseFirefox( | 364 var frame = |
368 '.convertDartClosureToJS/\$function</<@' | 365 new Frame.parseFirefox('.convertDartClosureToJS/\$function</<@' |
369 'http://pub.dartlang.org/stuff.dart.js:560'); | 366 'http://pub.dartlang.org/stuff.dart.js:560'); |
370 expect(frame.uri, | 367 expect(frame.uri, |
371 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); | 368 equals(Uri.parse("http://pub.dartlang.org/stuff.dart.js"))); |
372 expect(frame.line, equals(560)); | 369 expect(frame.line, equals(560)); |
373 expect(frame.column, isNull); | 370 expect(frame.column, isNull); |
374 expect(frame.member, equals("convertDartClosureToJS.<fn>.<fn>")); | 371 expect(frame.member, equals("convertDartClosureToJS.<fn>.<fn>")); |
375 }); | 372 }); |
376 | 373 |
377 test('returns an UnparsedFrame for malformed frames', () { | 374 test('returns an UnparsedFrame for malformed frames', () { |
378 expectIsUnparsed((text) => new Frame.parseFirefox(text), ''); | 375 expectIsUnparsed((text) => new Frame.parseFirefox(text), ''); |
379 expectIsUnparsed((text) => new Frame.parseFirefox(text), '.foo'); | 376 expectIsUnparsed((text) => new Frame.parseFirefox(text), '.foo'); |
380 expectIsUnparsed((text) => new Frame.parseFirefox(text), | 377 expectIsUnparsed((text) => new Frame.parseFirefox(text), |
381 '.foo@dart:async/future.dart'); | 378 '.foo@dart:async/future.dart'); |
382 expectIsUnparsed((text) => new Frame.parseFirefox(text), | 379 expectIsUnparsed((text) => new Frame.parseFirefox(text), |
383 '.foo(@dart:async/future.dart:10'); | 380 '.foo(@dart:async/future.dart:10'); |
384 expectIsUnparsed((text) => new Frame.parseFirefox(text), | 381 expectIsUnparsed( |
385 '@dart:async/future.dart'); | 382 (text) => new Frame.parseFirefox(text), '@dart:async/future.dart'); |
386 }); | 383 }); |
387 | 384 |
388 test('parses a simple stack frame correctly', () { | 385 test('parses a simple stack frame correctly', () { |
389 var frame = new Frame.parseFirefox( | 386 var frame = new Frame.parseFirefox( |
390 "foo\$bar@http://dartlang.org/foo/bar.dart:10:11"); | 387 "foo\$bar@http://dartlang.org/foo/bar.dart:10:11"); |
391 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | 388 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); |
392 expect(frame.line, equals(10)); | 389 expect(frame.line, equals(10)); |
393 expect(frame.column, equals(11)); | 390 expect(frame.column, equals(11)); |
394 expect(frame.member, equals('foo\$bar')); | 391 expect(frame.member, equals('foo\$bar')); |
395 }); | 392 }); |
396 | 393 |
397 test('parses an anonymous stack frame correctly', () { | 394 test('parses an anonymous stack frame correctly', () { |
398 var frame = new Frame.parseFirefox( | 395 var frame = |
399 "http://dartlang.org/foo/bar.dart:10:11"); | 396 new Frame.parseFirefox("http://dartlang.org/foo/bar.dart:10:11"); |
400 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | 397 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); |
401 expect(frame.line, equals(10)); | 398 expect(frame.line, equals(10)); |
402 expect(frame.column, equals(11)); | 399 expect(frame.column, equals(11)); |
403 expect(frame.member, equals('<fn>')); | 400 expect(frame.member, equals('<fn>')); |
404 }); | 401 }); |
405 | 402 |
406 test('parses a stack frame with no line correctly', () { | 403 test('parses a stack frame with no line correctly', () { |
407 var frame = new Frame.parseFirefox( | 404 var frame = new Frame.parseFirefox( |
408 "foo\$bar@http://dartlang.org/foo/bar.dart::11"); | 405 "foo\$bar@http://dartlang.org/foo/bar.dart::11"); |
409 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | 406 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 440 |
444 test('parses a stack frame with no line or column correctly', () { | 441 test('parses a stack frame with no line or column correctly', () { |
445 var frame = new Frame.parseFriendly( | 442 var frame = new Frame.parseFriendly( |
446 "http://dartlang.org/foo/bar.dart Foo.<fn>.bar"); | 443 "http://dartlang.org/foo/bar.dart Foo.<fn>.bar"); |
447 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | 444 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); |
448 expect(frame.line, isNull); | 445 expect(frame.line, isNull); |
449 expect(frame.column, isNull); | 446 expect(frame.column, isNull); |
450 expect(frame.member, equals('Foo.<fn>.bar')); | 447 expect(frame.member, equals('Foo.<fn>.bar')); |
451 }); | 448 }); |
452 | 449 |
453 test('parses a stack frame with no line correctly', () { | 450 test('parses a stack frame with no column correctly', () { |
454 var frame = new Frame.parseFriendly( | 451 var frame = new Frame.parseFriendly( |
455 "http://dartlang.org/foo/bar.dart 10 Foo.<fn>.bar"); | 452 "http://dartlang.org/foo/bar.dart 10 Foo.<fn>.bar"); |
456 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); | 453 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); |
457 expect(frame.line, equals(10)); | 454 expect(frame.line, equals(10)); |
458 expect(frame.column, isNull); | 455 expect(frame.column, isNull); |
459 expect(frame.member, equals('Foo.<fn>.bar')); | 456 expect(frame.member, equals('Foo.<fn>.bar')); |
460 }); | 457 }); |
461 | 458 |
462 test('parses a stack frame with a relative path correctly', () { | 459 test('parses a stack frame with a relative path correctly', () { |
463 var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar"); | 460 var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar"); |
464 expect(frame.uri, equals( | 461 expect(frame.uri, |
465 path.toUri(path.absolute(path.join('foo', 'bar.dart'))))); | 462 equals(path.toUri(path.absolute(path.join('foo', 'bar.dart'))))); |
466 expect(frame.line, equals(10)); | 463 expect(frame.line, equals(10)); |
467 expect(frame.column, equals(11)); | 464 expect(frame.column, equals(11)); |
468 expect(frame.member, equals('Foo.<fn>.bar')); | 465 expect(frame.member, equals('Foo.<fn>.bar')); |
469 }); | 466 }); |
470 | 467 |
471 test('returns an UnparsedFrame for malformed frames', () { | 468 test('returns an UnparsedFrame for malformed frames', () { |
472 expectIsUnparsed((text) => new Frame.parseFriendly(text), ''); | 469 expectIsUnparsed((text) => new Frame.parseFriendly(text), ''); |
473 expectIsUnparsed((text) => new Frame.parseFriendly(text), 'foo/bar.dart'); | 470 expectIsUnparsed((text) => new Frame.parseFriendly(text), 'foo/bar.dart'); |
474 expectIsUnparsed((text) => new Frame.parseFriendly(text), | 471 expectIsUnparsed( |
475 'foo/bar.dart 10:11'); | 472 (text) => new Frame.parseFriendly(text), 'foo/bar.dart 10:11'); |
| 473 }); |
| 474 |
| 475 test('parses a data url stack frame with no line or column correctly', () { |
| 476 var frame = new Frame.parseFriendly("data:... main"); |
| 477 expect(frame.uri.scheme, equals('data')); |
| 478 expect(frame.line, isNull); |
| 479 expect(frame.column, isNull); |
| 480 expect(frame.member, equals('main')); |
| 481 }); |
| 482 |
| 483 test('parses a data url stack frame correctly', () { |
| 484 var frame = new Frame.parseFriendly("data:... 10:11 main"); |
| 485 expect(frame.uri.scheme, equals('data')); |
| 486 expect(frame.line, equals(10)); |
| 487 expect(frame.column, equals(11)); |
| 488 expect(frame.member, equals('main')); |
| 489 }); |
| 490 |
| 491 test('parses a stack frame with spaces in the member name correctly', () { |
| 492 var frame = new Frame.parseFriendly( |
| 493 "foo/bar.dart 10:11 (anonymous function).dart.fn"); |
| 494 expect(frame.uri, |
| 495 equals(path.toUri(path.absolute(path.join('foo', 'bar.dart'))))); |
| 496 expect(frame.line, equals(10)); |
| 497 expect(frame.column, equals(11)); |
| 498 expect(frame.member, equals('(anonymous function).dart.fn')); |
| 499 }); |
| 500 |
| 501 test( |
| 502 'parses a stack frame with spaces in the member name and no line or ' |
| 503 'column correctly', () { |
| 504 var frame = new Frame.parseFriendly( |
| 505 "http://dartlang.org/foo/bar.dart (anonymous function).dart.fn"); |
| 506 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart"))); |
| 507 expect(frame.line, isNull); |
| 508 expect(frame.column, isNull); |
| 509 expect(frame.member, equals('(anonymous function).dart.fn')); |
476 }); | 510 }); |
477 }); | 511 }); |
478 | 512 |
479 test('only considers dart URIs to be core', () { | 513 test('only considers dart URIs to be core', () { |
480 bool isCore(String library) => | 514 bool isCore(String library) => |
481 new Frame.parseVM('#0 Foo ($library:0:0)').isCore; | 515 new Frame.parseVM('#0 Foo ($library:0:0)').isCore; |
482 | 516 |
483 expect(isCore('dart:core'), isTrue); | 517 expect(isCore('dart:core'), isTrue); |
484 expect(isCore('dart:async'), isTrue); | 518 expect(isCore('dart:async'), isTrue); |
485 expect(isCore('dart:core/uri.dart'), isTrue); | 519 expect(isCore('dart:core/uri.dart'), isTrue); |
486 expect(isCore('dart:async/future.dart'), isTrue); | 520 expect(isCore('dart:async/future.dart'), isTrue); |
487 expect(isCore('bart:core'), isFalse); | 521 expect(isCore('bart:core'), isFalse); |
488 expect(isCore('sdart:core'), isFalse); | 522 expect(isCore('sdart:core'), isFalse); |
489 expect(isCore('darty:core'), isFalse); | 523 expect(isCore('darty:core'), isFalse); |
490 expect(isCore('bart:core/uri.dart'), isFalse); | 524 expect(isCore('bart:core/uri.dart'), isFalse); |
491 }); | 525 }); |
492 | 526 |
493 group('.library', () { | 527 group('.library', () { |
494 test('returns the URI string for non-file URIs', () { | 528 test('returns the URI string for non-file URIs', () { |
495 expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').library, | 529 expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').library, |
496 equals('dart:async/future.dart')); | 530 equals('dart:async/future.dart')); |
497 expect(new Frame.parseVM('#0 Foo ' | 531 expect( |
498 '(http://dartlang.org/stuff/thing.dart:0:0)').library, | 532 new Frame.parseVM('#0 Foo ' |
| 533 '(http://dartlang.org/stuff/thing.dart:0:0)') |
| 534 .library, |
499 equals('http://dartlang.org/stuff/thing.dart')); | 535 equals('http://dartlang.org/stuff/thing.dart')); |
500 }); | 536 }); |
501 | 537 |
502 test('returns the relative path for file URIs', () { | 538 test('returns the relative path for file URIs', () { |
503 expect(new Frame.parseVM('#0 Foo (foo/bar.dart:0:0)').library, | 539 expect(new Frame.parseVM('#0 Foo (foo/bar.dart:0:0)').library, |
504 equals(path.join('foo', 'bar.dart'))); | 540 equals(path.join('foo', 'bar.dart'))); |
505 }); | 541 }); |
506 | 542 |
507 test('truncates data: URIs', () { | 543 test('truncates data: URIs', () { |
508 var frame = new Frame.parseVM( | 544 var frame = new Frame.parseVM( |
509 '#0 Foo (data:application/dart;charset=utf-8,blah:0:0)'); | 545 '#0 Foo (data:application/dart;charset=utf-8,blah:0:0)'); |
510 expect(frame.library, equals('data:...')); | 546 expect(frame.library, equals('data:...')); |
511 }); | 547 }); |
512 }); | 548 }); |
513 | 549 |
514 group('.location', () { | 550 group('.location', () { |
515 test('returns the library and line/column numbers for non-core ' | 551 test( |
| 552 'returns the library and line/column numbers for non-core ' |
516 'libraries', () { | 553 'libraries', () { |
517 expect(new Frame.parseVM('#0 Foo ' | 554 expect( |
518 '(http://dartlang.org/thing.dart:5:10)').location, | 555 new Frame.parseVM('#0 Foo ' |
| 556 '(http://dartlang.org/thing.dart:5:10)') |
| 557 .location, |
519 equals('http://dartlang.org/thing.dart 5:10')); | 558 equals('http://dartlang.org/thing.dart 5:10')); |
520 expect(new Frame.parseVM('#0 Foo (foo/bar.dart:1:2)').location, | 559 expect(new Frame.parseVM('#0 Foo (foo/bar.dart:1:2)').location, |
521 equals('${path.join('foo', 'bar.dart')} 1:2')); | 560 equals('${path.join('foo', 'bar.dart')} 1:2')); |
522 }); | 561 }); |
523 }); | 562 }); |
524 | 563 |
525 group('.package', () { | 564 group('.package', () { |
526 test('returns null for non-package URIs', () { | 565 test('returns null for non-package URIs', () { |
527 expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').package, | 566 expect(new Frame.parseVM('#0 Foo (dart:async/future.dart:0:0)').package, |
528 isNull); | 567 isNull); |
529 expect(new Frame.parseVM('#0 Foo ' | 568 expect( |
530 '(http://dartlang.org/stuff/thing.dart:0:0)').package, | 569 new Frame.parseVM('#0 Foo ' |
| 570 '(http://dartlang.org/stuff/thing.dart:0:0)') |
| 571 .package, |
531 isNull); | 572 isNull); |
532 }); | 573 }); |
533 | 574 |
534 test('returns the package name for package: URIs', () { | 575 test('returns the package name for package: URIs', () { |
535 expect(new Frame.parseVM('#0 Foo (package:foo/foo.dart:0:0)').package, | 576 expect(new Frame.parseVM('#0 Foo (package:foo/foo.dart:0:0)').package, |
536 equals('foo')); | 577 equals('foo')); |
537 expect(new Frame.parseVM('#0 Foo (package:foo/zap/bar.dart:0:0)').package, | 578 expect(new Frame.parseVM('#0 Foo (package:foo/zap/bar.dart:0:0)').package, |
538 equals('foo')); | 579 equals('foo')); |
539 }); | 580 }); |
540 }); | 581 }); |
541 | 582 |
542 group('.toString()', () { | 583 group('.toString()', () { |
543 test('returns the library and line/column numbers for non-core ' | 584 test( |
| 585 'returns the library and line/column numbers for non-core ' |
544 'libraries', () { | 586 'libraries', () { |
545 expect(new Frame.parseVM('#0 Foo (http://dartlang.org/thing.dart:5:10)') | 587 expect( |
| 588 new Frame.parseVM('#0 Foo (http://dartlang.org/thing.dart:5:10)') |
546 .toString(), | 589 .toString(), |
547 equals('http://dartlang.org/thing.dart 5:10 in Foo')); | 590 equals('http://dartlang.org/thing.dart 5:10 in Foo')); |
548 }); | 591 }); |
549 | 592 |
550 test('converts "<anonymous closure>" to "<fn>"', () { | 593 test('converts "<anonymous closure>" to "<fn>"', () { |
551 expect(new Frame.parseVM('#0 Foo.<anonymous closure> ' | 594 expect( |
552 '(dart:core/uri.dart:5:10)').toString(), | 595 new Frame.parseVM('#0 Foo.<anonymous closure> ' |
| 596 '(dart:core/uri.dart:5:10)') |
| 597 .toString(), |
553 equals('dart:core/uri.dart 5:10 in Foo.<fn>')); | 598 equals('dart:core/uri.dart 5:10 in Foo.<fn>')); |
554 }); | 599 }); |
555 | 600 |
556 test('prints a frame without a column correctly', () { | 601 test('prints a frame without a column correctly', () { |
557 expect(new Frame.parseVM('#0 Foo (dart:core/uri.dart:5)').toString(), | 602 expect(new Frame.parseVM('#0 Foo (dart:core/uri.dart:5)').toString(), |
558 equals('dart:core/uri.dart 5 in Foo')); | 603 equals('dart:core/uri.dart 5 in Foo')); |
559 }); | 604 }); |
560 | 605 |
561 test('prints relative paths as relative', () { | 606 test('prints relative paths as relative', () { |
562 var relative = path.normalize('relative/path/to/foo.dart'); | 607 var relative = path.normalize('relative/path/to/foo.dart'); |
563 expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), | 608 expect(new Frame.parseFriendly('$relative 5:10 Foo').toString(), |
564 equals('$relative 5:10 in Foo')); | 609 equals('$relative 5:10 in Foo')); |
565 }); | 610 }); |
566 }); | 611 }); |
567 } | 612 } |
568 | 613 |
569 void expectIsUnparsed(Frame constructor(String text), String text) { | 614 void expectIsUnparsed(Frame constructor(String text), String text) { |
570 var frame = constructor(text); | 615 var frame = constructor(text); |
571 expect(frame, new isInstanceOf<UnparsedFrame>()); | 616 expect(frame, new isInstanceOf<UnparsedFrame>()); |
572 expect(frame.toString(), equals(text)); | 617 expect(frame.toString(), equals(text)); |
573 } | 618 } |
OLD | NEW |