Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: pkg/stack_trace/test/trace_test.dart

Issue 13191011: Be more careful about converting between file URIs and paths. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/stack_trace/test/frame_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
11 import 'package:stack_trace/src/utils.dart';
11 import 'package:stack_trace/stack_trace.dart'; 12 import 'package:stack_trace/stack_trace.dart';
12 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
13 14
14 String getStackTraceString() { 15 String getStackTraceString() {
15 try { 16 try {
16 throw ''; 17 throw '';
17 } catch (_, stackTrace) { 18 } catch (_, stackTrace) {
18 return stackTrace.toString(); 19 return stackTrace.toString();
19 } 20 }
20 } 21 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 var trace = nestedGetCurrentTrace(2); 85 var trace = nestedGetCurrentTrace(2);
85 expect(trace.frames.first.member, equals('main.<fn>.<fn>')); 86 expect(trace.frames.first.member, equals('main.<fn>.<fn>'));
86 }); 87 });
87 88
88 test('throws an ArgumentError for negative levels', () { 89 test('throws an ArgumentError for negative levels', () {
89 expect(() => new Trace.current(-1), throwsArgumentError); 90 expect(() => new Trace.current(-1), throwsArgumentError);
90 }); 91 });
91 }); 92 });
92 93
93 test('.toString() nicely formats the stack trace', () { 94 test('.toString() nicely formats the stack trace', () {
94 var uri = _pathToFileUri(path.join('foo', 'bar.dart')); 95 var uri = pathToFileUri(path.join('foo', 'bar.dart'));
95 var trace = new Trace.parse(''' 96 var trace = new Trace.parse('''
96 #0 Foo._bar ($uri:42:21) 97 #0 Foo._bar ($uri:42:21)
97 #1 zip.<anonymous closure>.zap (dart:async:0:2) 98 #1 zip.<anonymous closure>.zap (dart:async:0:2)
98 #2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.dart:1:100) 99 #2 zip.<anonymous closure>.zap (http://pub.dartlang.org/thing.dart:1:100)
99 '''); 100 ''');
100 101
101 expect(trace.toString(), equals(''' 102 expect(trace.toString(), equals('''
102 ${path.join('foo', 'bar.dart')} 42:21 Foo._bar 103 ${path.join('foo', 'bar.dart')} 42:21 Foo._bar
103 dart:async zip.<fn>.zap 104 dart:async zip.<fn>.zap
104 http://pub.dartlang.org/thing.dart 1:100 zip.<fn>.zap 105 http://pub.dartlang.org/thing.dart 1:100 zip.<fn>.zap
(...skipping 21 matching lines...) Expand all
126 '''); 127 ''');
127 128
128 expect(trace.terse.toString(), equals(''' 129 expect(trace.terse.toString(), equals('''
129 foo.dart 42:21 notCore 130 foo.dart 42:21 notCore
130 dart:core bottom 131 dart:core bottom
131 bar.dart 10:20 alsoNotCore 132 bar.dart 10:20 alsoNotCore
132 dart:async bottom 133 dart:async bottom
133 ''')); 134 '''));
134 }); 135 });
135 } 136 }
136
137 String _pathToFileUri(String pathString) {
138 pathString = path.absolute(pathString);
139 if (Platform.operatingSystem != 'windows') return 'file://$pathString';
140 return 'file:///${pathString.replaceAll("\\", "/")}';
141 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/test/frame_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698