Chromium Code Reviews| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 * }); | 149 * }); |
| 150 * }); | 150 * }); |
| 151 * } | 151 * } |
| 152 * | 152 * |
| 153 */ | 153 */ |
| 154 library unittest; | 154 library unittest; |
| 155 | 155 |
| 156 import 'dart:async'; | 156 import 'dart:async'; |
| 157 import 'dart:isolate'; | 157 import 'dart:isolate'; |
| 158 import 'matcher.dart'; | 158 import 'matcher.dart'; |
| 159 import 'package:meta/meta.dart'; | |
|
Siggi Cherem (dart-lang)
2013/03/24 17:20:09
unfortunately this library is used within the dart
Andrei Mouravski
2013/03/24 18:49:23
From what I remember, this wasn't working because
| |
| 159 export 'matcher.dart'; | 160 export 'matcher.dart'; |
| 160 | 161 |
| 161 // TODO(amouravski): We should not need to import mock here, but it's necessary | 162 // TODO(amouravski): We should not need to import mock here, but it's necessary |
| 162 // to enable dartdoc on the mock library, as it's not picked up normally. | 163 // to enable dartdoc on the mock library, as it's not picked up normally. |
| 163 import 'mock.dart'; | 164 import 'mock.dart'; |
| 164 | 165 |
| 165 part 'src/config.dart'; | 166 part 'src/config.dart'; |
| 166 part 'src/test_case.dart'; | 167 part 'src/test_case.dart'; |
| 167 | 168 |
| 169 Configuration _config; | |
| 170 | |
| 168 /** [Configuration] used by the unittest library. */ | 171 /** [Configuration] used by the unittest library. */ |
| 169 Configuration _config = null; | |
| 170 | |
| 171 Configuration get config => _config; | 172 Configuration get config => _config; |
| 172 | 173 |
| 173 /** | 174 /** |
| 174 * Set the [Configuration] used by the unittest library. Returns any | 175 * Set the [Configuration] used by the unittest library. |
| 175 * previous configuration. | 176 * |
| 176 * TODO: consider deprecating in favor of a setter now we have a getter. | 177 * Throws an exception if a value has already been set. |
| 177 */ | 178 */ |
| 179 void set config(Configuration value) { | |
| 180 if(_config != null) { | |
| 181 throw 'config has already been set'; | |
| 182 } | |
| 183 _config = value; | |
| 184 } | |
| 185 | |
| 186 /** | |
| 187 * Use [config] instead. | |
| 188 */ | |
| 189 @deprecated | |
| 178 Configuration configure(Configuration config) { | 190 Configuration configure(Configuration config) { |
| 179 Configuration _oldConfig = _config; | 191 Configuration _oldConfig = _config; |
| 180 _config = config; | 192 _config = config; |
| 181 return _oldConfig; | 193 return _oldConfig; |
| 182 } | 194 } |
| 183 | 195 |
| 184 void logMessage(String message) => _config.logMessage(message); | 196 void logMessage(String message) => _config.logMessage(message); |
| 185 | 197 |
| 186 /** | 198 /** |
| 187 * Description text of the current test group. If multiple groups are nested, | 199 * Description text of the current test group. If multiple groups are nested, |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 } | 819 } |
| 808 _initialized = true; | 820 _initialized = true; |
| 809 // Hook our async guard into the matcher library. | 821 // Hook our async guard into the matcher library. |
| 810 wrapAsync = (f, [id]) => expectAsync1(f, id: id); | 822 wrapAsync = (f, [id]) => expectAsync1(f, id: id); |
| 811 | 823 |
| 812 _tests = <TestCase>[]; | 824 _tests = <TestCase>[]; |
| 813 _testRunner = _nextBatch; | 825 _testRunner = _nextBatch; |
| 814 _uncaughtErrorMessage = null; | 826 _uncaughtErrorMessage = null; |
| 815 | 827 |
| 816 if (_config == null) { | 828 if (_config == null) { |
| 817 _config = new Configuration(); | 829 config = new Configuration(); |
|
Siggi Cherem (dart-lang)
2013/03/24 17:20:09
let's keep this with _config (you already checked
| |
| 818 } | 830 } |
| 819 _config.onInit(); | 831 _config.onInit(); |
| 820 | 832 |
| 821 if (_config.autoStart) { | 833 if (_config.autoStart) { |
| 822 // Immediately queue the suite up. It will run after a timeout (i.e. after | 834 // Immediately queue the suite up. It will run after a timeout (i.e. after |
| 823 // main() has returned). | 835 // main() has returned). |
| 824 _defer(runTests); | 836 _defer(runTests); |
| 825 } | 837 } |
| 826 } | 838 } |
| 827 | 839 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 851 } | 863 } |
| 852 | 864 |
| 853 /** Enable a test by ID. */ | 865 /** Enable a test by ID. */ |
| 854 void enableTest(int testId) => _setTestEnabledState(testId, true); | 866 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 855 | 867 |
| 856 /** Disable a test by ID. */ | 868 /** Disable a test by ID. */ |
| 857 void disableTest(int testId) => _setTestEnabledState(testId, false); | 869 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 858 | 870 |
| 859 /** Signature for a test function. */ | 871 /** Signature for a test function. */ |
| 860 typedef dynamic TestFunction(); | 872 typedef dynamic TestFunction(); |
| OLD | NEW |