| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * A library for writing dart unit tests. | 6 * A library for writing dart unit tests. |
| 7 * | 7 * |
| 8 * To import this library, specify the relative path to | 8 * To import this library, specify the relative path to |
| 9 * pkg/unittest/unittest.dart. | 9 * pkg/unittest/unittest.dart. |
| 10 * | 10 * |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // imply that the test fails). We can't do it without also changing | 212 // imply that the test fails). We can't do it without also changing |
| 213 // the testrunner and test.dart though. | 213 // the testrunner and test.dart though. |
| 214 const PASS = 'pass'; | 214 const PASS = 'pass'; |
| 215 const FAIL = 'fail'; | 215 const FAIL = 'fail'; |
| 216 const ERROR = 'error'; | 216 const ERROR = 'error'; |
| 217 | 217 |
| 218 /** If set, then all other test cases will be ignored. */ | 218 /** If set, then all other test cases will be ignored. */ |
| 219 TestCase _soloTest; | 219 TestCase _soloTest; |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * A map that can be used to communicate state between a test driver |
| 223 * or main() function and the tests, particularly when these two |
| 224 * are otherwise independent. For example, a test driver that starts |
| 225 * an HTTP server and then runs tests that access that server could use |
| 226 * this as a way of communicating the server port to the tests. |
| 227 */ |
| 228 Map testState = {}; |
| 229 |
| 230 /** |
| 222 * (Deprecated) Evaluates the [function] and validates that it throws an | 231 * (Deprecated) Evaluates the [function] and validates that it throws an |
| 223 * exception. If [callback] is provided, then it will be invoked with the | 232 * exception. If [callback] is provided, then it will be invoked with the |
| 224 * thrown exception. The callback may do any validation it wants. In addition, | 233 * thrown exception. The callback may do any validation it wants. In addition, |
| 225 * if it returns `false`, that also indicates an expectation failure. | 234 * if it returns `false`, that also indicates an expectation failure. |
| 226 */ | 235 */ |
| 227 void expectThrow(function, [bool callback(exception)]) { | 236 void expectThrow(function, [bool callback(exception)]) { |
| 228 bool threw = false; | 237 bool threw = false; |
| 229 try { | 238 try { |
| 230 function(); | 239 function(); |
| 231 } catch (e) { | 240 } catch (e) { |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 } | 886 } |
| 878 | 887 |
| 879 /** Enable a test by ID. */ | 888 /** Enable a test by ID. */ |
| 880 void enableTest(int testId) => _setTestEnabledState(testId, true); | 889 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 881 | 890 |
| 882 /** Disable a test by ID. */ | 891 /** Disable a test by ID. */ |
| 883 void disableTest(int testId) => _setTestEnabledState(testId, false); | 892 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 884 | 893 |
| 885 /** Signature for a test function. */ | 894 /** Signature for a test function. */ |
| 886 typedef void TestFunction(); | 895 typedef void TestFunction(); |
| OLD | NEW |