| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 Completer _testComplete; | 64 Completer _testComplete; |
| 65 | 65 |
| 66 TestCase._internal(this.id, this.description, this.testFunction) | 66 TestCase._internal(this.id, this.description, this.testFunction) |
| 67 : currentGroup = _currentContext.fullName, | 67 : currentGroup = _currentContext.fullName, |
| 68 setUp = _currentContext.testSetup, | 68 setUp = _currentContext.testSetup, |
| 69 tearDown = _currentContext.testTeardown; | 69 tearDown = _currentContext.testTeardown; |
| 70 | 70 |
| 71 bool get isComplete => !enabled || result != null; | 71 bool get isComplete => !enabled || result != null; |
| 72 | 72 |
| 73 Function _errorHandler(String stage) => (e) { | 73 Function _errorHandler(String stage) => (Object e, StackTrace stack) { |
| 74 var stack; | |
| 75 // TODO(kevmoo): Ideally, getAttachedStackTrace should handle Error as well? | |
| 76 // https://code.google.com/p/dart/issues/detail?id=12240 | |
| 77 if(e is Error) { | |
| 78 stack = e.stackTrace; | |
| 79 } else { | |
| 80 stack = getAttachedStackTrace(e); | |
| 81 } | |
| 82 if (result == null || result == PASS) { | 74 if (result == null || result == PASS) { |
| 83 if (e is TestFailure) { | 75 if (e is TestFailure) { |
| 84 fail("$e", stack); | 76 fail("$e", stack); |
| 85 } else { | 77 } else { |
| 86 error("$stage failed: Caught $e", stack); | 78 error("$stage failed: Caught $e", stack); |
| 87 } | 79 } |
| 88 } | 80 } |
| 89 }; | 81 }; |
| 90 | 82 |
| 91 /** | 83 /** |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 178 } |
| 187 | 179 |
| 188 void _markCallbackComplete() { | 180 void _markCallbackComplete() { |
| 189 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { | 181 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { |
| 190 pass(); | 182 pass(); |
| 191 } | 183 } |
| 192 } | 184 } |
| 193 | 185 |
| 194 String toString() => _result != null ? "$description: $result" : description; | 186 String toString() => _result != null ? "$description: $result" : description; |
| 195 } | 187 } |
| OLD | NEW |