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

Side by Side Diff: tests/language/stacktrace_rethrow_error_test.dart

Issue 342473006: Don't add the catch frame at a rethrow to the stacktrace. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 class SubclassOfError extends Error {}
6
7 fail() => throw "Fail";
8
9 // == Rethrow, skipping through typed handlers. ==
10
11 aa1() {
12 try {
13 bb1();
14 fail();
15 } catch(error
16 , stacktrace /// withtraceparameter: ok
17 ) {
18 expectTrace(['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], error.stackTr ace);
19 expectTrace(['gg1', 'ff1', 'ee1', 'dd1', 'cc1', 'bb1', 'aa1'], stacktrace); /// withtraceparameter: continued
20 }
21 }
22
23 bb1() => cc1();
24
25 cc1() {
26 try {
27 dd1();
28 } on String catch(e) {
29 fail();
30 } on int catch(e) {
31 fail();
32 }
33 }
34
35 dd1() => ee1();
36
37 ee1() {
38 try {
39 ff1();
40 } catch(e) {
41 rethrow;
42 }
43 }
44
45 ff1() => gg1();
46
47 gg1() => throw new SubclassOfError();
48
49 // == Rethrow, rethrow again in typed handler. ==
50
51 aa2() {
52 try {
53 bb2();
54 fail();
55 } catch(error
56 , stacktrace /// withtraceparameter: continued
57 ) {
58 expectTrace(['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], error.stackTr ace);
59 expectTrace(['gg2', 'ff2', 'ee2', 'dd2', 'cc2', 'bb2', 'aa2'], stacktrace); /// withtraceparameter: continued
60 }
61 }
62
63 bb2() => cc2();
64
65 cc2() {
66 try {
67 dd2();
68 } on SubclassOfError catch(e) {
69 rethrow;
70 } on int catch(e) {
71 fail();
72 }
73 }
74
75 dd2() => ee2();
76
77 ee2() {
78 try {
79 ff2();
80 } catch(e) {
81 rethrow;
82 }
83 }
84
85 ff2() => gg2();
86
87 gg2() => throw new SubclassOfError();
88
89 // == Rethrow, with intervening catch without a trace parameter.
90
91 aa3() {
92 try {
93 bb3();
94 fail();
95 } catch(error
96 , stacktrace /// withtraceparameter: continued
97 ) {
98 expectTrace(['gg3', 'ff3', 'ee3', 'dd3', 'cc3', 'bb3', 'aa3'], error.stackTr ace);
99 expectTrace(['cc3', 'bb3', 'aa3'], stacktrace); /// withtraceparameter: con tinued
100 }
101 }
102
103 bb3() => cc3();
104
105 cc3() {
106 try {
107 dd3();
108 } catch(e) {
109 throw e;
110 }
111 }
112
113 dd3() => ee3();
114
115 ee3() {
116 try {
117 ff3();
118 } catch(e) {
119 rethrow;
120 }
121 }
122
123 ff3() => gg3();
124
125 gg3() => throw new SubclassOfError();
126
127 expectTrace(functionNames, stacktrace) {
128 // Note we don't expect functionNames to cover the whole trace, only the
129 // top portion, because the frames below main are an implementation detail.
130 var traceLines = stacktrace.toString().split('\n');
131 var expectedIndex = 0;
132 var actualIndex = 0;
133 print(stacktrace);
134 print(functionNames);
135 while (expectedIndex < functionNames.length) {
136 var expected = functionNames[expectedIndex];
137 var actual = traceLines[actualIndex];
138 if (actual.indexOf(expected) == -1) {
139 if (expectedIndex == 0) {
140 actualIndex++; // Skip over some helper frames at the top
141 } else {
142 throw "Expected: $expected actual: $actual";
143 }
144 } else {
145 actualIndex++;
146 expectedIndex++;
147 }
148 }
149 }
150
151 main() {
152 aa1();
153 aa2();
154 aa3();
155 }
OLDNEW
« no previous file with comments | « tests/language/language_dart2js.status ('k') | tests/language/stacktrace_rethrow_nonerror_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698