| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 * // indicate that the asynchronous callback was invoked. | 141 * // indicate that the asynchronous callback was invoked. |
| 142 * async.complete(); | 142 * async.complete(); |
| 143 * }); | 143 * }); |
| 144 * }); | 144 * }); |
| 145 * } | 145 * } |
| 146 * | 146 * |
| 147 */ | 147 */ |
| 148 library unittest; | 148 library unittest; |
| 149 | 149 |
| 150 import 'dart:isolate'; | 150 import 'dart:isolate'; |
| 151 import 'matcher.dart'; |
| 152 export 'matcher.dart'; |
| 151 | 153 |
| 152 part 'collection_matchers.dart'; | |
| 153 part 'config.dart'; | 154 part 'config.dart'; |
| 154 part 'core_matchers.dart'; | |
| 155 part 'description.dart'; | |
| 156 part 'expect.dart'; | |
| 157 part 'future_matchers.dart'; | |
| 158 part 'interfaces.dart'; | |
| 159 part 'map_matchers.dart'; | |
| 160 part 'matcher.dart'; | |
| 161 part 'mock.dart'; | |
| 162 part 'numeric_matchers.dart'; | |
| 163 part 'operator_matchers.dart'; | |
| 164 part 'string_matchers.dart'; | |
| 165 part 'test_case.dart'; | 155 part 'test_case.dart'; |
| 166 | 156 |
| 167 /** [Configuration] used by the unittest library. */ | 157 /** [Configuration] used by the unittest library. */ |
| 168 Configuration _config = null; | 158 Configuration _config = null; |
| 169 | 159 |
| 170 Configuration get config => _config; | 160 Configuration get config => _config; |
| 171 | 161 |
| 172 /** | 162 /** |
| 173 * Set the [Configuration] used by the unittest library. Returns any | 163 * Set the [Configuration] used by the unittest library. Returns any |
| 174 * previous configuration. | 164 * previous configuration. |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 } | 837 } |
| 848 | 838 |
| 849 /** | 839 /** |
| 850 * Lazily initializes the test library if not already initialized. | 840 * Lazily initializes the test library if not already initialized. |
| 851 */ | 841 */ |
| 852 ensureInitialized() { | 842 ensureInitialized() { |
| 853 if (_initialized) { | 843 if (_initialized) { |
| 854 return; | 844 return; |
| 855 } | 845 } |
| 856 _initialized = true; | 846 _initialized = true; |
| 847 // Hook our async guard into the matcher library. |
| 848 wrapAsync = expectAsync1; |
| 857 | 849 |
| 858 _tests = <TestCase>[]; | 850 _tests = <TestCase>[]; |
| 859 _testRunner = _nextBatch; | 851 _testRunner = _nextBatch; |
| 860 _uncaughtErrorMessage = null; | 852 _uncaughtErrorMessage = null; |
| 861 | 853 |
| 862 if (_config == null) { | 854 if (_config == null) { |
| 863 _config = new Configuration(); | 855 _config = new Configuration(); |
| 864 } | 856 } |
| 865 _config.onInit(); | 857 _config.onInit(); |
| 866 | 858 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 897 } | 889 } |
| 898 | 890 |
| 899 /** Enable a test by ID. */ | 891 /** Enable a test by ID. */ |
| 900 void enableTest(int testId) => _setTestEnabledState(testId, true); | 892 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 901 | 893 |
| 902 /** Disable a test by ID. */ | 894 /** Disable a test by ID. */ |
| 903 void disableTest(int testId) => _setTestEnabledState(testId, false); | 895 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 904 | 896 |
| 905 /** Signature for a test function. */ | 897 /** Signature for a test function. */ |
| 906 typedef void TestFunction(); | 898 typedef void TestFunction(); |
| OLD | NEW |