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, use the pub package manager. | 8 * To import this library, use the pub package manager. |
9 * Create a pubspec.yaml file in your project and add | 9 * Create a pubspec.yaml file in your project and add |
10 * a dependency on unittest with the following lines: | 10 * a dependency on unittest with the following lines: |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 return guardAsync( | 425 return guardAsync( |
426 () { | 426 () { |
427 ++_actualCalls; | 427 ++_actualCalls; |
428 if (_shouldCallBack()) { | 428 if (_shouldCallBack()) { |
429 return _callback(arg1, arg2); | 429 return _callback(arg1, arg2); |
430 } | 430 } |
431 }, | 431 }, |
432 _after, _testNum); | 432 _after, _testNum); |
433 } | 433 } |
434 | 434 |
435 /** Returns false if we exceded the number of expected calls. */ | 435 /** Returns true if we have not exceeded the number of expected calls. */ |
436 bool _checkCallCount() { | 436 bool _checkCallCount() { |
437 if (_actualCalls > _expectedCalls) { | 437 if (_actualCalls > _expectedCalls) { |
438 _testCase.error('Callback ${_id}called more times than expected ' | 438 throw new TestFailure('Callback ${_id}called more times than expected ' |
439 '($_actualCalls > $_expectedCalls).', ''); | 439 '($_actualCalls > $_expectedCalls).'); |
440 return false; | 440 return false; |
Jennifer Messerly
2013/02/27 22:42:55
remove?
| |
441 } | 441 } |
442 return true; | 442 return true; |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 /** | 446 /** |
447 * Indicate that [callback] is expected to be called a [count] number of times | 447 * Indicate that [callback] is expected to be called a [count] number of times |
448 * (by default 1). The unittest framework will wait for the callback to run the | 448 * (by default 1). The unittest framework will wait for the callback to run the |
449 * specified [count] times before it continues with the following test. Using | 449 * specified [count] times before it continues with the following test. Using |
450 * [_expectAsync] will also ensure that errors that occur within [callback] are | 450 * [_expectAsync] will also ensure that errors that occur within [callback] are |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 } | 881 } |
882 | 882 |
883 /** Enable a test by ID. */ | 883 /** Enable a test by ID. */ |
884 void enableTest(int testId) => _setTestEnabledState(testId, true); | 884 void enableTest(int testId) => _setTestEnabledState(testId, true); |
885 | 885 |
886 /** Disable a test by ID. */ | 886 /** Disable a test by ID. */ |
887 void disableTest(int testId) => _setTestEnabledState(testId, false); | 887 void disableTest(int testId) => _setTestEnabledState(testId, false); |
888 | 888 |
889 /** Signature for a test function. */ | 889 /** Signature for a test function. */ |
890 typedef dynamic TestFunction(); | 890 typedef dynamic TestFunction(); |
OLD | NEW |