| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 _soloTest = new TestCase(_tests.length + 1, _fullSpec(spec), body, 0); | 292 _soloTest = new TestCase(_tests.length + 1, _fullSpec(spec), body, 0); |
| 293 _tests.add(_soloTest); | 293 _tests.add(_soloTest); |
| 294 } | 294 } |
| 295 | 295 |
| 296 /** Sentinel value for [_SpreadArgsHelper]. */ | 296 /** Sentinel value for [_SpreadArgsHelper]. */ |
| 297 class _Sentinel { | 297 class _Sentinel { |
| 298 const _Sentinel(); | 298 const _Sentinel(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 // TODO(sigmund): make a singleton const field when frog supports passing those | |
| 302 // as default values to named arguments. | |
| 303 const _sentinel = const _Sentinel(); | |
| 304 | |
| 305 /** Simulates spread arguments using named arguments. */ | 301 /** Simulates spread arguments using named arguments. */ |
| 306 // TODO(sigmund): remove this class and simply use a closure with named | 302 // TODO(sigmund): remove this class and simply use a closure with named |
| 307 // arguments (if still applicable). | 303 // arguments (if still applicable). |
| 308 class _SpreadArgsHelper { | 304 class _SpreadArgsHelper { |
| 309 Function _callback; | 305 Function _callback; |
| 310 int _expectedCalls; | 306 int _expectedCalls; |
| 311 int _actualCalls = 0; | 307 int _actualCalls = 0; |
| 312 int _testNum; | 308 int _testNum; |
| 313 TestCase _testCase; | 309 TestCase _testCase; |
| 314 Function _shouldCallBack; | 310 Function _shouldCallBack; |
| 315 Function _isDone; | 311 Function _isDone; |
| 312 static const _sentinel = const _Sentinel(); |
| 316 | 313 |
| 317 _init(Function callback, Function shouldCallBack, Function isDone, | 314 _init(Function callback, Function shouldCallBack, Function isDone, |
| 318 [expectedCalls = 0]) { | 315 [expectedCalls = 0]) { |
| 319 ensureInitialized(); | 316 ensureInitialized(); |
| 320 assert(_currentTest >= 0 && | 317 assert(_currentTest >= 0 && |
| 321 _currentTest < _tests.length && | 318 _currentTest < _tests.length && |
| 322 _tests[_currentTest] != null); | 319 _tests[_currentTest] != null); |
| 323 _callback = callback; | 320 _callback = callback; |
| 324 _shouldCallBack = shouldCallBack; | 321 _shouldCallBack = shouldCallBack; |
| 325 _isDone = isDone; | 322 _isDone = isDone; |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 } | 866 } |
| 870 | 867 |
| 871 /** Enable a test by ID. */ | 868 /** Enable a test by ID. */ |
| 872 void enableTest(int testId) => _setTestEnabledState(testId, true); | 869 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 873 | 870 |
| 874 /** Disable a test by ID. */ | 871 /** Disable a test by ID. */ |
| 875 void disableTest(int testId) => _setTestEnabledState(testId, false); | 872 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 876 | 873 |
| 877 /** Signature for a test function. */ | 874 /** Signature for a test function. */ |
| 878 typedef void TestFunction(); | 875 typedef void TestFunction(); |
| OLD | NEW |