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

Side by Side Diff: pkg/unittest/lib/src/test_case.dart

Issue 21905005: pkg/unittest: get stackTrace from error directly (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: delegating TODO Created 7 years, 4 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 | « no previous file | 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 part of unittest; 5 part of unittest;
6 6
7 /** 7 /**
8 * Represents the state for an individual unit test. 8 * Represents the state for an individual unit test.
9 * 9 *
10 * Create by calling [test] or [solo_test]. 10 * Create by calling [test] or [solo_test].
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 Completer _testComplete; 61 Completer _testComplete;
62 62
63 TestCase._internal(this.id, this.description, this.testFunction) 63 TestCase._internal(this.id, this.description, this.testFunction)
64 : currentGroup = _currentContext.fullName, 64 : currentGroup = _currentContext.fullName,
65 setUp = _currentContext.testSetup, 65 setUp = _currentContext.testSetup,
66 tearDown = _currentContext.testTeardown; 66 tearDown = _currentContext.testTeardown;
67 67
68 bool get isComplete => !enabled || result != null; 68 bool get isComplete => !enabled || result != null;
69 69
70 Function _errorHandler(String stage) => (e) { 70 Function _errorHandler(String stage) => (e) {
71 var stack = getAttachedStackTrace(e); 71 var stack;
72 // TODO(kevmoo): Ideally, getAttachedStackTrace should handle Error as well?
73 // https://code.google.com/p/dart/issues/detail?id=12240
74 if(e is Error) {
75 stack = e.stackTrace;
76 } else {
77 stack = getAttachedStackTrace(e);
78 }
72 if (result == null || result == PASS) { 79 if (result == null || result == PASS) {
73 if (e is TestFailure) { 80 if (e is TestFailure) {
74 fail("$e", stack); 81 fail("$e", stack);
75 } else { 82 } else {
76 error("$stage failed: Caught $e", stack); 83 error("$stage failed: Caught $e", stack);
77 } 84 }
78 } 85 }
79 }; 86 };
80 87
81 /** 88 /**
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void error(String messageText, [stack]) { 179 void error(String messageText, [stack]) {
173 _complete(ERROR, messageText, stack); 180 _complete(ERROR, messageText, stack);
174 } 181 }
175 182
176 void _markCallbackComplete() { 183 void _markCallbackComplete() {
177 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { 184 if (--_callbackFunctionsOutstanding == 0 && !isComplete) {
178 pass(); 185 pass();
179 } 186 }
180 } 187 }
181 } 188 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698