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

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

Issue 812253002: Delete a bunch of packages that are now on GitHub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Un-delete http Created 6 years 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/utils.dart ('k') | pkg/string_scanner/CHANGELOG.md » ('j') | 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:path/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 expect(path.url.basename(trace.frames.first.uri.path),
47 equals('vm_test.dart'));
48 expect(trace.frames.first.member, equals('getStackTraceString'));
49 });
50
51 test('converts from a native stack trace correctly', () {
52 var trace = new Trace.from(getStackTraceObject());
53 expect(path.url.basename(trace.frames.first.uri.path),
54 equals('vm_test.dart'));
55 expect(trace.frames.first.member, equals('getStackTraceObject'));
56 });
57
58 group('.current()', () {
59 test('with no argument returns a trace starting at the current frame',
60 () {
61 var trace = new Trace.current();
62 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
63 });
64
65 test('at level 0 returns a trace starting at the current frame', () {
66 var trace = new Trace.current(0);
67 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
68 });
69
70 test('at level 1 returns a trace starting at the parent frame', () {
71 var trace = getCurrentTrace(1);
72 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
73 });
74
75 test('at level 2 returns a trace starting at the grandparent frame', () {
76 var trace = nestedGetCurrentTrace(2);
77 expect(trace.frames.first.member, equals('main.<fn>.<fn>.<fn>'));
78 });
79
80 test('throws an ArgumentError for negative levels', () {
81 expect(() => new Trace.current(-1), throwsArgumentError);
82 });
83 });
84 });
85
86 group('Frame.caller()', () {
87 test('with no argument returns the parent frame', () {
88 expect(getCaller().member, equals('main.<fn>.<fn>'));
89 });
90
91 test('at level 0 returns the current frame', () {
92 expect(getCaller(0).member, equals('getCaller'));
93 });
94
95 test('at level 1 returns the current frame', () {
96 expect(getCaller(1).member, equals('main.<fn>.<fn>'));
97 });
98
99 test('at level 2 returns the grandparent frame', () {
100 expect(nestedGetCaller(2).member, equals('main.<fn>.<fn>'));
101 });
102
103 test('throws an ArgumentError for negative levels', () {
104 expect(() => new Frame.caller(-1), throwsArgumentError);
105 });
106 });
107 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/test/utils.dart ('k') | pkg/string_scanner/CHANGELOG.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698