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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 * tracked and reported. [callback] should take 0 positional arguments (named | 474 * tracked and reported. [callback] should take 0 positional arguments (named |
475 * arguments are not supported). | 475 * arguments are not supported). |
476 */ | 476 */ |
477 // TODO(sigmund): deprecate this API when issue 2706 is fixed. | 477 // TODO(sigmund): deprecate this API when issue 2706 is fixed. |
478 Function expectAsync0(Function callback, [int count = 1]) { | 478 Function expectAsync0(Function callback, [int count = 1]) { |
479 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke0; | 479 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke0; |
480 } | 480 } |
481 | 481 |
482 /** Like [expectAsync0] but [callback] should take 1 positional argument. */ | 482 /** Like [expectAsync0] but [callback] should take 1 positional argument. */ |
483 // TODO(sigmund): deprecate this API when issue 2706 is fixed. | 483 // TODO(sigmund): deprecate this API when issue 2706 is fixed. |
484 Function expectAsync1(Function callback, [int count = 1]) { | 484 Function expectAsync1(Function callback, {int count: 1}) { |
485 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke1; | 485 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke1; |
486 } | 486 } |
487 | 487 |
488 /** Like [expectAsync0] but [callback] should take 2 positional arguments. */ | 488 /** Like [expectAsync0] but [callback] should take 2 positional arguments. */ |
489 // TODO(sigmund): deprecate this API when issue 2706 is fixed. | 489 // TODO(sigmund): deprecate this API when issue 2706 is fixed. |
490 Function expectAsync2(Function callback, [int count = 1]) { | 490 Function expectAsync2(Function callback, [int count = 1]) { |
491 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke2; | 491 return new _SpreadArgsHelper.fixedCallCount(callback, count).invoke2; |
492 } | 492 } |
493 | 493 |
494 /** | 494 /** |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 * [done] or if it fails with an exception. | 790 * [done] or if it fails with an exception. |
791 */ | 791 */ |
792 _nextBatch() { | 792 _nextBatch() { |
793 while (_currentTest < _tests.length) { | 793 while (_currentTest < _tests.length) { |
794 final testCase = _tests[_currentTest]; | 794 final testCase = _tests[_currentTest]; |
795 guardAsync(() { | 795 guardAsync(() { |
796 testCase.run(); | 796 testCase.run(); |
797 if (!testCase.isComplete && testCase.callbackFunctionsOutstanding == 0) { | 797 if (!testCase.isComplete && testCase.callbackFunctionsOutstanding == 0) { |
798 testCase.pass(); | 798 testCase.pass(); |
799 } | 799 } |
800 }, testNum:_currentTest); | 800 }, null, _currentTest); |
801 | 801 |
802 if (!testCase.isComplete && | 802 if (!testCase.isComplete && |
803 testCase.callbackFunctionsOutstanding > 0) return; | 803 testCase.callbackFunctionsOutstanding > 0) return; |
804 _currentTest++; | 804 _currentTest++; |
805 } | 805 } |
806 | 806 |
807 _completeTests(); | 807 _completeTests(); |
808 } | 808 } |
809 | 809 |
810 /** Publish results on the page and notify controller. */ | 810 /** Publish results on the page and notify controller. */ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 } | 886 } |
887 | 887 |
888 /** Enable a test by ID. */ | 888 /** Enable a test by ID. */ |
889 void enableTest(int testId) => _setTestEnabledState(testId, true); | 889 void enableTest(int testId) => _setTestEnabledState(testId, true); |
890 | 890 |
891 /** Disable a test by ID. */ | 891 /** Disable a test by ID. */ |
892 void disableTest(int testId) => _setTestEnabledState(testId, false); | 892 void disableTest(int testId) => _setTestEnabledState(testId, false); |
893 | 893 |
894 /** Signature for a test function. */ | 894 /** Signature for a test function. */ |
895 typedef void TestFunction(); | 895 typedef void TestFunction(); |
OLD | NEW |