| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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, install the | 8 * To import this library, install the |
| 9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub | 9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub |
| 10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc) | 10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc) |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 /** | 661 /** |
| 662 * Runs [callback] at the end of the event loop. Note that we don't wrap | 662 * Runs [callback] at the end of the event loop. Note that we don't wrap |
| 663 * the callback in guardAsync; this is for test framework functions which | 663 * the callback in guardAsync; this is for test framework functions which |
| 664 * should not be throwing unexpected exceptions that end up failing test | 664 * should not be throwing unexpected exceptions that end up failing test |
| 665 * cases! Furthermore, we need the final exception to be thrown but not | 665 * cases! Furthermore, we need the final exception to be thrown but not |
| 666 * caught by the test framework if any test cases failed. However, tests | 666 * caught by the test framework if any test cases failed. However, tests |
| 667 * that make use of a similar defer function *should* wrap the callback | 667 * that make use of a similar defer function *should* wrap the callback |
| 668 * (as we do in unitttest_test.dart). | 668 * (as we do in unitttest_test.dart). |
| 669 */ | 669 */ |
| 670 _defer(void callback()) { | 670 _defer(void callback()) { |
| 671 (new Future.immediate(null)).then((_) => callback()); | 671 (new Future.value()).then((_) => callback()); |
| 672 } | 672 } |
| 673 | 673 |
| 674 void rerunTests() { | 674 void rerunTests() { |
| 675 _uncaughtErrorMessage = null; | 675 _uncaughtErrorMessage = null; |
| 676 _initialized = true; // We don't want to reset the test array. | 676 _initialized = true; // We don't want to reset the test array. |
| 677 runTests(); | 677 runTests(); |
| 678 } | 678 } |
| 679 | 679 |
| 680 /** | 680 /** |
| 681 * Filter the tests. [testFilter] can be a [RegExp], a [String] or a | 681 * Filter the tests. [testFilter] can be a [RegExp], a [String] or a |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 } | 857 } |
| 858 | 858 |
| 859 /** Enable a test by ID. */ | 859 /** Enable a test by ID. */ |
| 860 void enableTest(int testId) => _setTestEnabledState(testId, true); | 860 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 861 | 861 |
| 862 /** Disable a test by ID. */ | 862 /** Disable a test by ID. */ |
| 863 void disableTest(int testId) => _setTestEnabledState(testId, false); | 863 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 864 | 864 |
| 865 /** Signature for a test function. */ | 865 /** Signature for a test function. */ |
| 866 typedef dynamic TestFunction(); | 866 typedef dynamic TestFunction(); |
| OLD | NEW |