| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |