Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1307)

Unified Diff: pkg/unittest/lib/unittest.dart

Issue 12770017: pkg/unittest: config refactor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: per siggi's recomendations Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/unittest/lib/unittest.dart
diff --git a/pkg/unittest/lib/unittest.dart b/pkg/unittest/lib/unittest.dart
index 0d9a549b727c8603f17a8377dabdbed44cfe4637..9bb75808ad944a9e127b077ed8d089c5ca4146d0 100644
--- a/pkg/unittest/lib/unittest.dart
+++ b/pkg/unittest/lib/unittest.dart
@@ -156,6 +156,7 @@ library unittest;
import 'dart:async';
import 'dart:isolate';
import 'matcher.dart';
+import 'package:meta/meta.dart';
export 'matcher.dart';
// TODO(amouravski): We should not need to import mock here, but it's necessary
@@ -165,20 +166,33 @@ import 'mock.dart';
part 'src/config.dart';
part 'src/test_case.dart';
-/** [Configuration] used by the unittest library. */
-Configuration _config = null;
+Configuration _config;
+/** [Configuration] used by the unittest library. */
Configuration get config => _config;
/**
- * Set the [Configuration] used by the unittest library. Returns any
- * previous configuration.
- * TODO: consider deprecating in favor of a setter now we have a getter.
+ * Sets the [Configuration] used by the unittest library.
+ *
+ * Throws an exception if a value has already been set to a different value.
+ */
+void set config(Configuration value) {
+ if(!identical(_config, value)) {
+ if(_config != null) {
+ throw 'config has already been set';
+ }
+ _config = value;
+ }
+}
+
+/**
+ * Use [config] instead.
*/
-Configuration configure(Configuration config) {
- Configuration _oldConfig = _config;
- _config = config;
- return _oldConfig;
+@deprecated
+Configuration configure(Configuration value) {
+ var oldConfig = config;
+ config = value;
+ return oldConfig;
}
void logMessage(String message) => _config.logMessage(message);
@@ -807,7 +821,7 @@ void ensureInitialized() {
_uncaughtErrorMessage = null;
if (_config == null) {
- _config = new Configuration();
+ config = new Configuration();
}
_config.onInit();

Powered by Google App Engine
This is Rietveld 408576698