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 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:uri'; | 8 import 'dart:uri'; |
9 | 9 |
10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 void main() { | 35 void main() { |
36 test('parses a stack trace correctly', () { | 36 test('parses a stack trace correctly', () { |
37 var trace = new Trace.parse(''' | 37 var trace = new Trace.parse(''' |
38 #0 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21) | 38 #0 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21) |
39 #1 zip.<anonymous closure>.zap (dart:async:0:2) | 39 #1 zip.<anonymous closure>.zap (dart:async:0:2) |
40 #2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.dart:1:100) | 40 #2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.dart:1:100) |
41 '''); | 41 '''); |
42 | 42 |
43 expect(trace.frames[0].uri, | 43 expect(trace.frames[0].uri, |
44 equals(new Uri.fromString("file:///home/nweiz/code/stuff.dart"))); | 44 equals(Uri.parse("file:///home/nweiz/code/stuff.dart"))); |
45 expect(trace.frames[1].uri, equals(new Uri.fromString("dart:async"))); | 45 expect(trace.frames[1].uri, equals(Uri.parse("dart:async"))); |
46 expect(trace.frames[2].uri, | 46 expect(trace.frames[2].uri, |
47 equals(new Uri.fromString("http://pub.dartlang.org/thing.dart"))); | 47 equals(Uri.parse("http://pub.dartlang.org/thing.dart"))); |
48 }); | 48 }); |
49 | 49 |
50 test('parses a real stack trace correctly', () { | 50 test('parses a real stack trace correctly', () { |
51 var trace = new Trace.parse(getStackTraceString()); | 51 var trace = new Trace.parse(getStackTraceString()); |
52 // TODO(nweiz): use URL-style paths when such a thing exists. | 52 // TODO(nweiz): use URL-style paths when such a thing exists. |
53 var builder = new path.Builder(style: path.Style.posix); | 53 var builder = new path.Builder(style: path.Style.posix); |
54 expect(builder.basename(trace.frames.first.uri.path), | 54 expect(builder.basename(trace.frames.first.uri.path), |
55 equals('trace_test.dart')); | 55 equals('trace_test.dart')); |
56 expect(trace.frames.first.member, equals('getStackTraceString')); | 56 expect(trace.frames.first.member, equals('getStackTraceString')); |
57 }); | 57 }); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); | 147 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); |
148 expect(folded.toString(), equals(''' | 148 expect(folded.toString(), equals(''' |
149 foo.dart 42:21 notFoo | 149 foo.dart 42:21 notFoo |
150 foo.dart 1:100 fooBottom | 150 foo.dart 1:100 fooBottom |
151 bar.dart 10:20 alsoNotFoo | 151 bar.dart 10:20 alsoNotFoo |
152 dart:async-patch fooBottom | 152 dart:async-patch fooBottom |
153 ''')); | 153 ''')); |
154 }); | 154 }); |
155 } | 155 } |
OLD | NEW |