| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 Function _testTeardown; | 193 Function _testTeardown; |
| 194 | 194 |
| 195 /** Current test being executed. */ | 195 /** Current test being executed. */ |
| 196 int _currentTest = 0; | 196 int _currentTest = 0; |
| 197 | 197 |
| 198 /** Whether the framework is in an initialized state. */ | 198 /** Whether the framework is in an initialized state. */ |
| 199 bool _initialized = false; | 199 bool _initialized = false; |
| 200 | 200 |
| 201 String _uncaughtErrorMessage = null; | 201 String _uncaughtErrorMessage = null; |
| 202 | 202 |
| 203 final _PASS = 'pass'; | 203 const _PASS = 'pass'; |
| 204 final _FAIL = 'fail'; | 204 const _FAIL = 'fail'; |
| 205 final _ERROR = 'error'; | 205 const _ERROR = 'error'; |
| 206 | 206 |
| 207 /** If set, then all other test cases will be ignored. */ | 207 /** If set, then all other test cases will be ignored. */ |
| 208 TestCase _soloTest; | 208 TestCase _soloTest; |
| 209 | 209 |
| 210 /** | 210 /** |
| 211 * (Deprecated) Evaluates the [function] and validates that it throws an | 211 * (Deprecated) Evaluates the [function] and validates that it throws an |
| 212 * exception. If [callback] is provided, then it will be invoked with the | 212 * exception. If [callback] is provided, then it will be invoked with the |
| 213 * thrown exception. The callback may do any validation it wants. In addition, | 213 * thrown exception. The callback may do any validation it wants. In addition, |
| 214 * if it returns `false`, that also indicates an expectation failure. | 214 * if it returns `false`, that also indicates an expectation failure. |
| 215 */ | 215 */ |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 _tests.add(_soloTest); | 295 _tests.add(_soloTest); |
| 296 } | 296 } |
| 297 | 297 |
| 298 /** Sentinel value for [_SpreadArgsHelper]. */ | 298 /** Sentinel value for [_SpreadArgsHelper]. */ |
| 299 class _Sentinel { | 299 class _Sentinel { |
| 300 const _Sentinel(); | 300 const _Sentinel(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 // TODO(sigmund): make a singleton const field when frog supports passing those | 303 // TODO(sigmund): make a singleton const field when frog supports passing those |
| 304 // as default values to named arguments. | 304 // as default values to named arguments. |
| 305 final _sentinel = const _Sentinel(); | 305 const _sentinel = const _Sentinel(); |
| 306 | 306 |
| 307 /** Simulates spread arguments using named arguments. */ | 307 /** Simulates spread arguments using named arguments. */ |
| 308 // TODO(sigmund): remove this class and simply use a closure with named | 308 // TODO(sigmund): remove this class and simply use a closure with named |
| 309 // arguments (if still applicable). | 309 // arguments (if still applicable). |
| 310 class _SpreadArgsHelper { | 310 class _SpreadArgsHelper { |
| 311 Function _callback; | 311 Function _callback; |
| 312 int _expectedCalls; | 312 int _expectedCalls; |
| 313 int _actualCalls = 0; | 313 int _actualCalls = 0; |
| 314 int _testNum; | 314 int _testNum; |
| 315 TestCase _testCase; | 315 TestCase _testCase; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 } | 852 } |
| 853 | 853 |
| 854 /** Enable a test by ID. */ | 854 /** Enable a test by ID. */ |
| 855 void enableTest(int testId) => _setTestEnabledState(testId, true); | 855 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 856 | 856 |
| 857 /** Disable a test by ID. */ | 857 /** Disable a test by ID. */ |
| 858 void disableTest(int testId) => _setTestEnabledState(testId, false); | 858 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 859 | 859 |
| 860 /** Signature for a test function. */ | 860 /** Signature for a test function. */ |
| 861 typedef void TestFunction(); | 861 typedef void TestFunction(); |
| OLD | NEW |