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

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

Issue 18029023: Add a couple functions to package:stack_trace. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 5 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/lib/src/vm_trace.dart ('k') | pkg/stack_trace/test/trace_test.dart » ('j') | 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 frame_test; 5 library frame_test;
6 6
7 import 'package:pathos/path.dart' as path; 7 import 'package:pathos/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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 expect(() => new Frame.parseFirefox('.foo'), throwsFormatException); 178 expect(() => new Frame.parseFirefox('.foo'), throwsFormatException);
179 expect(() => new Frame.parseFirefox('.foo@dart:async/future.dart'), 179 expect(() => new Frame.parseFirefox('.foo@dart:async/future.dart'),
180 throwsFormatException); 180 throwsFormatException);
181 expect(() => new Frame.parseFirefox('.foo(@dart:async/future.dart:10'), 181 expect(() => new Frame.parseFirefox('.foo(@dart:async/future.dart:10'),
182 throwsFormatException); 182 throwsFormatException);
183 expect(() => new Frame.parseFirefox('@dart:async/future.dart'), 183 expect(() => new Frame.parseFirefox('@dart:async/future.dart'),
184 throwsFormatException); 184 throwsFormatException);
185 }); 185 });
186 }); 186 });
187 187
188 group('.parseFriendly', () {
189 test('parses a simple stack frame correctly', () {
190 var frame = new Frame.parseFriendly(
191 "http://dartlang.org/foo/bar.dart 10:11 Foo.<fn>.bar");
192 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
193 expect(frame.line, equals(10));
194 expect(frame.column, equals(11));
195 expect(frame.member, equals('Foo.<fn>.bar'));
196 });
197
198 test('parses a stack frame with no line or column correctly', () {
199 var frame = new Frame.parseFriendly(
200 "http://dartlang.org/foo/bar.dart Foo.<fn>.bar");
201 expect(frame.uri, equals(Uri.parse("http://dartlang.org/foo/bar.dart")));
202 expect(frame.line, isNull);
203 expect(frame.column, isNull);
204 expect(frame.member, equals('Foo.<fn>.bar'));
205 });
206
207 test('parses a stack frame with a relative path correctly', () {
208 var frame = new Frame.parseFriendly("foo/bar.dart 10:11 Foo.<fn>.bar");
209 expect(frame.uri, equals(
210 path.toUri(path.absolute(path.join('foo', 'bar.dart')))));
211 expect(frame.line, equals(10));
212 expect(frame.column, equals(11));
213 expect(frame.member, equals('Foo.<fn>.bar'));
214 });
215
216 test('throws a FormatException for malformed frames', () {
217 expect(() => new Frame.parseFriendly(''), throwsFormatException);
218 expect(() => new Frame.parseFriendly('foo/bar.dart'),
219 throwsFormatException);
220 expect(() => new Frame.parseFriendly('foo/bar.dart 10:11'),
221 throwsFormatException);
222 });
223 });
224
188 test('only considers dart URIs to be core', () { 225 test('only considers dart URIs to be core', () {
189 bool isCore(String library) => 226 bool isCore(String library) =>
190 new Frame.parseVM('#0 Foo ($library:0:0)').isCore; 227 new Frame.parseVM('#0 Foo ($library:0:0)').isCore;
191 228
192 expect(isCore('dart:core'), isTrue); 229 expect(isCore('dart:core'), isTrue);
193 expect(isCore('dart:async'), isTrue); 230 expect(isCore('dart:async'), isTrue);
194 expect(isCore('dart:core/uri.dart'), isTrue); 231 expect(isCore('dart:core/uri.dart'), isTrue);
195 expect(isCore('dart:async/future.dart'), isTrue); 232 expect(isCore('dart:async/future.dart'), isTrue);
196 expect(isCore('bart:core'), isFalse); 233 expect(isCore('bart:core'), isFalse);
197 expect(isCore('sdart:core'), isFalse); 234 expect(isCore('sdart:core'), isFalse);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 equals('http://dartlang.org/thing.dart 5:10 in Foo')); 287 equals('http://dartlang.org/thing.dart 5:10 in Foo'));
251 }); 288 });
252 289
253 test('converts "<anonymous closure>" to "<fn>"', () { 290 test('converts "<anonymous closure>" to "<fn>"', () {
254 expect(new Frame.parseVM('#0 Foo.<anonymous closure> ' 291 expect(new Frame.parseVM('#0 Foo.<anonymous closure> '
255 '(dart:core/uri.dart:5:10)').toString(), 292 '(dart:core/uri.dart:5:10)').toString(),
256 equals('dart:core/uri.dart 5:10 in Foo.<fn>')); 293 equals('dart:core/uri.dart 5:10 in Foo.<fn>'));
257 }); 294 });
258 }); 295 });
259 } 296 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/lib/src/vm_trace.dart ('k') | pkg/stack_trace/test/trace_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698