| 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 | 8 |
| 9 import 'package:pathos/path.dart' as path; | 9 import 'package:pathos/path.dart' as path; |
| 10 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 var trace = nestedGetCurrentTrace(2); | 83 var trace = nestedGetCurrentTrace(2); |
| 84 expect(trace.frames.first.member, equals('main.<fn>.<fn>')); | 84 expect(trace.frames.first.member, equals('main.<fn>.<fn>')); |
| 85 }); | 85 }); |
| 86 | 86 |
| 87 test('throws an ArgumentError for negative levels', () { | 87 test('throws an ArgumentError for negative levels', () { |
| 88 expect(() => new Trace.current(-1), throwsArgumentError); | 88 expect(() => new Trace.current(-1), throwsArgumentError); |
| 89 }); | 89 }); |
| 90 }); | 90 }); |
| 91 | 91 |
| 92 test('.toString() nicely formats the stack trace', () { | 92 test('.toString() nicely formats the stack trace', () { |
| 93 var uri = path.toUri(path.join('foo', 'bar.dart')); | |
| 94 var trace = new Trace.parse(''' | 93 var trace = new Trace.parse(''' |
| 95 #0 Foo._bar ($uri:42:21) | 94 #0 Foo._bar (foo/bar.dart:42:21) |
| 96 #1 zip.<anonymous closure>.zap (dart:async/future.dart:0:2) | 95 #1 zip.<anonymous closure>.zap (dart:async/future.dart:0:2) |
| 97 #2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.dart:1:100) | 96 #2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.dart:1:100) |
| 98 '''); | 97 '''); |
| 99 | 98 |
| 100 expect(trace.toString(), equals(''' | 99 expect(trace.toString(), equals(''' |
| 101 ${path.join('foo', 'bar.dart')} 42:21 Foo._bar | 100 foo/bar.dart 42:21 Foo._bar |
| 102 dart:async/future.dart 0:2 zip.<fn>.zap | 101 dart:async/future.dart 0:2 zip.<fn>.zap |
| 103 http://pub.dartlang.org/thing.dart 1:100 zip.<fn>.zap | 102 http://pub.dartlang.org/thing.dart 1:100 zip.<fn>.zap |
| 104 ''')); | 103 ''')); |
| 105 }); | 104 }); |
| 106 | 105 |
| 107 test('.stackTrace forwards to .toString()', () { | 106 test('.stackTrace forwards to .toString()', () { |
| 108 var trace = new Trace.current(); | 107 var trace = new Trace.current(); |
| 109 expect(trace.stackTrace, equals(trace.toString())); | 108 expect(trace.stackTrace, equals(trace.toString())); |
| 110 }); | 109 }); |
| 111 | 110 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 143 |
| 145 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); | 144 var folded = trace.foldFrames((frame) => frame.member.startsWith('foo')); |
| 146 expect(folded.toString(), equals(''' | 145 expect(folded.toString(), equals(''' |
| 147 foo.dart 42:21 notFoo | 146 foo.dart 42:21 notFoo |
| 148 foo.dart 1:100 fooBottom | 147 foo.dart 1:100 fooBottom |
| 149 bar.dart 10:20 alsoNotFoo | 148 bar.dart 10:20 alsoNotFoo |
| 150 dart:async-patch/future.dart 9:11 fooBottom | 149 dart:async-patch/future.dart 9:11 fooBottom |
| 151 ''')); | 150 ''')); |
| 152 }); | 151 }); |
| 153 } | 152 } |
| OLD | NEW |