| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 library unittest.internal_test_case; | 5 library unittest.internal_test_case; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../unittest.dart'; | 9 import '../unittest.dart'; |
| 10 import 'test_environment.dart'; | 10 import 'test_environment.dart'; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 /// Marks the test as having passed. | 187 /// Marks the test as having passed. |
| 188 void pass() { | 188 void pass() { |
| 189 _complete(PASS); | 189 _complete(PASS); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void registerException(error, [StackTrace stackTrace]) { | 192 void registerException(error, [StackTrace stackTrace]) { |
| 193 var message = error is TestFailure ? error.message : 'Caught $error'; | 193 var message = error is TestFailure ? error.message : 'Caught $error'; |
| 194 if (result == null) { | 194 if (result == null) { |
| 195 fail(message, stackTrace); | 195 fail(message, stackTrace); |
| 196 } else { | 196 } else { |
| 197 error(message, stackTrace); | 197 this.error(message, stackTrace); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 /// Marks the test as having failed. | 201 /// Marks the test as having failed. |
| 202 void fail(String messageText, [StackTrace stack]) { | 202 void fail(String messageText, [StackTrace stack]) { |
| 203 if (result != null) { | 203 if (result != null) { |
| 204 var newMessage = result == PASS | 204 var newMessage = result == PASS |
| 205 ? 'Test failed after initially passing: $messageText' | 205 ? 'Test failed after initially passing: $messageText' |
| 206 : 'Test failed more than once: $messageText'; | 206 : 'Test failed more than once: $messageText'; |
| 207 // TODO(gram): Should we combine the stack with the old one? | 207 // TODO(gram): Should we combine the stack with the old one? |
| (...skipping 10 matching lines...) Expand all Loading... |
| 218 | 218 |
| 219 /// Indicates that an asynchronous callback has completed, and marks the test | 219 /// Indicates that an asynchronous callback has completed, and marks the test |
| 220 /// as passing if all outstanding callbacks are complete. | 220 /// as passing if all outstanding callbacks are complete. |
| 221 void markCallbackComplete() { | 221 void markCallbackComplete() { |
| 222 callbackFunctionsOutstanding--; | 222 callbackFunctionsOutstanding--; |
| 223 if (callbackFunctionsOutstanding == 0 && !isComplete) pass(); | 223 if (callbackFunctionsOutstanding == 0 && !isComplete) pass(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 String toString() => result != null ? "$description: $result" : description; | 226 String toString() => result != null ? "$description: $result" : description; |
| 227 } | 227 } |
| OLD | NEW |