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

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

Issue 17998002: Revert "Add support for V8 and Firefox stack traces in pkg/stack_trace." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/test/trace_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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// This file tests stack_trace's ability to parse live stack traces. It's a
6 /// dual of dartium_test.dart, since method names can differ somewhat from
7 /// platform to platform. No similar file exists for dart2js since the specific
8 /// method names there are implementation details.
9
10 import 'package:pathos/path.dart' as path;
11 import 'package:stack_trace/stack_trace.dart';
12 import 'package:unittest/unittest.dart';
13
14 String getStackTraceString() {
15 try {
16 throw '';
17 } catch (_, stackTrace) {
18 return stackTrace.toString();
19 }
20 }
21
22 StackTrace getStackTraceObject() {
23 try {
24 throw '';
25 } catch (_, stackTrace) {
26 return stackTrace;
27 }
28 }
29
30 Frame getCaller([int level]) {
31 if (level == null) return new Frame.caller();
32 return new Frame.caller(level);
33 }
34
35 Frame nestedGetCaller(int level) => getCaller(level);
36
37 Trace getCurrentTrace([int level]) => new Trace.current(level);
38
39 Trace nestedGetCurrentTrace(int level) => getCurrentTrace(level);
40
41 void main() {
42 group('Trace', () {
43 test('.parse parses a real stack trace correctly', () {
44 var string = getStackTraceString();
45 var trace = new Trace.parse(string);
46 var builder = new path.Builder(style: path.Style.url);
47 expect(builder.basename(trace.frames.first.uri.path),
48 equals('vm_test.dart'));
49 expect(trace.frames.first.member, equals('getStackTraceString'));
50 });
51
52 test('converts from a native stack trace correctly', () {
53 var trace = new Trace.from(getStackTraceObject());
54 var builder = new path.Builder(style: path.Style.url);
55 expect(builder.basename(trace.frames.first.uri.path),
56 equals('vm_test.dart'));
57 expect(trace.frames.first.member, equals('getStackTraceObject'));
58 });
59
60 group('.current()', () {
61 test('with no argument returns a trace starting at the current frame',
62 () {
63 var trace = new Trace.current();
64 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
65 });
66
67 test('at level 0 returns a trace starting at the current frame', () {
68 var trace = new Trace.current(0);
69 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
70 });
71
72 test('at level 1 returns a trace starting at the parent frame', () {
73 var trace = getCurrentTrace(1);
74 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
75 });
76
77 test('at level 2 returns a trace starting at the grandparent frame', () {
78 var trace = nestedGetCurrentTrace(2);
79 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
80 });
81
82 test('throws an ArgumentError for negative levels', () {
83 expect(() => new Trace.current(-1), throwsArgumentError);
84 });
85 });
86 });
87
88 group('Frame.caller()', () {
89 test('with no argument returns the parent frame', () {
90 expect(getCaller().member, equals('main.<fn>.<fn>'));
91 });
92
93 test('at level 0 returns the current frame', () {
94 expect(getCaller(0).member, equals('getCaller'));
95 });
96
97 test('at level 1 returns the current frame', () {
98 expect(getCaller(1).member, equals('main.<fn>.<fn>'));
99 });
100
101 test('at level 2 returns the grandparent frame', () {
102 expect(nestedGetCaller(2).member, equals('main.<fn>.<fn>'));
103 });
104
105 test('throws an ArgumentError for negative levels', () {
106 expect(() => new Frame.caller(-1), throwsArgumentError);
107 });
108 });
109 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/test/trace_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698