| 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 * tracked and reported. [callback] should take 0 positional arguments (named | 465 * tracked and reported. [callback] should take 0 positional arguments (named |
| 466 * arguments are not supported). | 466 * arguments are not supported). |
| 467 */ | 467 */ |
| 468 // TODO(sigmund): deprecate this API when issue 2706 is fixed. | 468 // TODO(sigmund): deprecate this API when issue 2706 is fixed. |
| 469 Function expectAsync0(Function callback, [int count = 1]) { | 469 Function expectAsync0(Function callback, [int count = 1]) { |
| 470 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke0; | 470 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke0; |
| 471 } | 471 } |
| 472 | 472 |
| 473 /** Like [expectAsync0] but [callback] should take 1 positional argument. */ | 473 /** Like [expectAsync0] but [callback] should take 1 positional argument. */ |
| 474 // TODO(sigmund): deprecate this API when issue 2706 is fixed. | 474 // TODO(sigmund): deprecate this API when issue 2706 is fixed. |
| 475 Function expectAsync1(Function callback, [int count = 1]) { | 475 Function expectAsync1(Function callback, {int count: 1}) { |
| 476 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke1; | 476 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke1; |
| 477 } | 477 } |
| 478 | 478 |
| 479 /** Like [expectAsync0] but [callback] should take 2 positional arguments. */ | 479 /** Like [expectAsync0] but [callback] should take 2 positional arguments. */ |
| 480 // TODO(sigmund): deprecate this API when issue 2706 is fixed. | 480 // TODO(sigmund): deprecate this API when issue 2706 is fixed. |
| 481 Function expectAsync2(Function callback, [int count = 1]) { | 481 Function expectAsync2(Function callback, [int count = 1]) { |
| 482 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke2; | 482 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke2; |
| 483 } | 483 } |
| 484 | 484 |
| 485 /** | 485 /** |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 * [done] or if it fails with an exception. | 781 * [done] or if it fails with an exception. |
| 782 */ | 782 */ |
| 783 _nextBatch() { | 783 _nextBatch() { |
| 784 while (_currentTest < _tests.length) { | 784 while (_currentTest < _tests.length) { |
| 785 final testCase = _tests[_currentTest]; | 785 final testCase = _tests[_currentTest]; |
| 786 guardAsync(() { | 786 guardAsync(() { |
| 787 testCase.run(); | 787 testCase.run(); |
| 788 if (!testCase.isComplete && testCase.callbackFunctionsOutstanding == 0) { | 788 if (!testCase.isComplete && testCase.callbackFunctionsOutstanding == 0) { |
| 789 testCase.pass(); | 789 testCase.pass(); |
| 790 } | 790 } |
| 791 }, testNum:_currentTest); | 791 }, null, _currentTest); |
| 792 | 792 |
| 793 if (!testCase.isComplete && | 793 if (!testCase.isComplete && |
| 794 testCase.callbackFunctionsOutstanding > 0) return; | 794 testCase.callbackFunctionsOutstanding > 0) return; |
| 795 _currentTest++; | 795 _currentTest++; |
| 796 } | 796 } |
| 797 | 797 |
| 798 _completeTests(); | 798 _completeTests(); |
| 799 } | 799 } |
| 800 | 800 |
| 801 /** Publish results on the page and notify controller. */ | 801 /** Publish results on the page and notify controller. */ |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 } | 877 } |
| 878 | 878 |
| 879 /** Enable a test by ID. */ | 879 /** Enable a test by ID. */ |
| 880 void enableTest(int testId) => _setTestEnabledState(testId, true); | 880 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 881 | 881 |
| 882 /** Disable a test by ID. */ | 882 /** Disable a test by ID. */ |
| 883 void disableTest(int testId) => _setTestEnabledState(testId, false); | 883 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 884 | 884 |
| 885 /** Signature for a test function. */ | 885 /** Signature for a test function. */ |
| 886 typedef void TestFunction(); | 886 typedef void TestFunction(); |
| OLD | NEW |