| 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 trace_test; | 5 library trace_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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 '(http://pub.dartlang.org/thing.js:1:100)'); | 85 '(http://pub.dartlang.org/thing.js:1:100)'); |
| 86 | 86 |
| 87 expect(trace.frames[0].uri, | 87 expect(trace.frames[0].uri, |
| 88 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 88 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 89 expect(trace.frames[1].uri, | 89 expect(trace.frames[1].uri, |
| 90 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 90 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 91 expect(trace.frames[2].uri, | 91 expect(trace.frames[2].uri, |
| 92 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); | 92 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); |
| 93 }); | 93 }); |
| 94 | 94 |
| 95 test('parses a Firefox stack trace correctly', () { | 95 test('parses a Firefox/Safari stack trace correctly', () { |
| 96 var trace = new Trace.parse( | 96 var trace = new Trace.parse( |
| 97 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' | 97 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' |
| 98 'zip/<@http://pub.dartlang.org/stuff.js:0\n' | 98 'zip/<@http://pub.dartlang.org/stuff.js:0\n' |
| 99 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); | 99 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); |
| 100 | 100 |
| 101 expect(trace.frames[0].uri, | 101 expect(trace.frames[0].uri, |
| 102 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 102 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 103 expect(trace.frames[1].uri, | 103 expect(trace.frames[1].uri, |
| 104 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 104 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 105 expect(trace.frames[2].uri, | 105 expect(trace.frames[2].uri, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 123 'Foo._bar@http://pub.dartlang.org/stuff.js:42'); | 123 'Foo._bar@http://pub.dartlang.org/stuff.js:42'); |
| 124 | 124 |
| 125 expect(trace.frames[0].uri, | 125 expect(trace.frames[0].uri, |
| 126 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); | 126 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); |
| 127 expect(trace.frames[1].uri, | 127 expect(trace.frames[1].uri, |
| 128 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 128 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 129 expect(trace.frames[2].uri, | 129 expect(trace.frames[2].uri, |
| 130 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 130 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 131 }); | 131 }); |
| 132 | 132 |
| 133 test('parses a Safari 6.0 stack trace correctly', () { | 133 test('parses a Firefox/Safari stack trace containing native code correctly', |
| 134 () { |
| 134 var trace = new Trace.parse( | 135 var trace = new Trace.parse( |
| 135 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' | 136 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' |
| 136 'zip/<@http://pub.dartlang.org/stuff.js:0\n' | 137 'zip/<@http://pub.dartlang.org/stuff.js:0\n' |
| 137 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1\n' | 138 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1\n' |
| 138 '[native code]'); | 139 '[native code]'); |
| 139 | 140 |
| 140 expect(trace.frames[0].uri, | 141 expect(trace.frames[0].uri, |
| 141 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 142 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 142 expect(trace.frames[1].uri, | 143 expect(trace.frames[1].uri, |
| 143 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 144 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 144 expect(trace.frames[2].uri, | 145 expect(trace.frames[2].uri, |
| 145 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); | 146 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); |
| 146 expect(trace.frames.length, equals(3)); | 147 expect(trace.frames.length, equals(3)); |
| 147 }); | 148 }); |
| 148 | 149 |
| 149 test('parses a Safari 6.1 stack trace correctly', () { | 150 test('parses a Firefox/Safari stack trace without a method name correctly', |
| 151 () { |
| 150 var trace = new Trace.parse( | 152 var trace = new Trace.parse( |
| 151 'http://pub.dartlang.org/stuff.js:42:43\n' | 153 'http://pub.dartlang.org/stuff.js:42\n' |
| 152 'zip@http://pub.dartlang.org/stuff.js:0:1\n' | 154 'zip/<@http://pub.dartlang.org/stuff.js:0\n' |
| 153 'zip\$zap@http://pub.dartlang.org/thing.js:1:2'); | 155 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); |
| 156 |
| 157 expect(trace.frames[0].uri, |
| 158 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 159 expect(trace.frames[0].member, equals('<fn>')); |
| 160 expect(trace.frames[1].uri, |
| 161 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 162 expect(trace.frames[2].uri, |
| 163 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); |
| 164 }); |
| 165 |
| 166 test('parses a Firefox/Safari stack trace with an empty line correctly', |
| 167 () { |
| 168 var trace = new Trace.parse( |
| 169 'Foo._bar@http://pub.dartlang.org/stuff.js:42\n' |
| 170 '\n' |
| 171 'zip/<@http://pub.dartlang.org/stuff.js:0\n' |
| 172 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); |
| 154 | 173 |
| 155 expect(trace.frames[0].uri, | 174 expect(trace.frames[0].uri, |
| 156 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 175 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 157 expect(trace.frames[1].uri, | 176 expect(trace.frames[1].uri, |
| 158 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 177 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 159 expect(trace.frames[2].uri, | 178 expect(trace.frames[2].uri, |
| 160 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); | 179 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); |
| 161 }); | 180 }); |
| 162 | 181 |
| 163 test('parses a Safari 6.1 stack trace with an empty line correctly', () { | 182 test('parses a Firefox/Safari stack trace with a column number correctly', |
| 183 () { |
| 164 var trace = new Trace.parse( | 184 var trace = new Trace.parse( |
| 165 'http://pub.dartlang.org/stuff.js:42:43\n' | 185 'Foo._bar@http://pub.dartlang.org/stuff.js:42:2\n' |
| 166 '\n' | 186 'zip/<@http://pub.dartlang.org/stuff.js:0\n' |
| 167 'zip@http://pub.dartlang.org/stuff.js:0:1\n' | 187 'zip.zap(12, "@)()/<")@http://pub.dartlang.org/thing.js:1'); |
| 168 'zip\$zap@http://pub.dartlang.org/thing.js:1:2'); | |
| 169 | 188 |
| 170 expect(trace.frames[0].uri, | 189 expect(trace.frames[0].uri, |
| 171 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 190 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 191 expect(trace.frames[0].line, equals(42)); |
| 192 expect(trace.frames[0].column, equals(2)); |
| 172 expect(trace.frames[1].uri, | 193 expect(trace.frames[1].uri, |
| 173 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); | 194 equals(Uri.parse("http://pub.dartlang.org/stuff.js"))); |
| 174 expect(trace.frames[2].uri, | 195 expect(trace.frames[2].uri, |
| 175 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); | 196 equals(Uri.parse("http://pub.dartlang.org/thing.js"))); |
| 176 }); | 197 }); |
| 177 | 198 |
| 178 test('parses a package:stack_trace stack trace correctly', () { | 199 test('parses a package:stack_trace stack trace correctly', () { |
| 179 var trace = new Trace.parse( | 200 var trace = new Trace.parse( |
| 180 'http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar\n' | 201 'http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar\n' |
| 181 'http://dartlang.org/foo/baz.dart Foo.<fn>.bar'); | 202 'http://dartlang.org/foo/baz.dart Foo.<fn>.bar'); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 295 |
| 275 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); | 296 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); |
| 276 expect(folded.toString(), equals(''' | 297 expect(folded.toString(), equals(''' |
| 277 foo.dart 42:21 notFoo | 298 foo.dart 42:21 notFoo |
| 278 foo.dart 1:100 fooBottom | 299 foo.dart 1:100 fooBottom |
| 279 bar.dart 10:20 alsoNotFoo | 300 bar.dart 10:20 alsoNotFoo |
| 280 dart:async-patch/future.dart 9:11 fooBottom | 301 dart:async-patch/future.dart 9:11 fooBottom |
| 281 ''')); | 302 ''')); |
| 282 }); | 303 }); |
| 283 } | 304 } |
| OLD | NEW |