Index: pkg/unittest/lib/unittest.dart |
diff --git a/pkg/unittest/lib/unittest.dart b/pkg/unittest/lib/unittest.dart |
index 57f25812c9f8edabc456c86639fc31b0891ea391..5fa2ae9ed66f5ecb68ce6de8ad56f3d74c4c5177 100644 |
--- a/pkg/unittest/lib/unittest.dart |
+++ b/pkg/unittest/lib/unittest.dart |
@@ -299,11 +299,6 @@ void solo_test(String spec, TestFunction body) { |
} |
} |
-/** Sentinel value for [_SpreadArgsHelper]. */ |
-class _Sentinel { |
- const _Sentinel(); |
-} |
- |
/** |
* Indicate that [callback] is expected to be called a [count] number of times |
* (by default 1). The unittest framework will wait for the callback to run the |
@@ -371,33 +366,39 @@ Function expectAsyncUntil2(Function callback, Function isDone, {String id}) { |
} |
/** |
- * Wraps the [callback] in a new function and returns that function. The new |
- * function will be able to handle exceptions by directing them to the correct |
- * test. This is thus similar to expectAsync0. Use it to wrap any callbacks that |
- * might optionally be called but may never be called during the test. |
- * [callback] should take 0 positional arguments (named arguments are not |
- * supported). [id] can be used to identify the callback in error |
- * messages (for example if it is called after the test case is complete). |
+ * *Deprecated* |
+ * |
+ * All tests are now run an isolated [Zone]. |
+ * |
+ * You can safely remove calls to this method. |
*/ |
-// TODO(sigmund): deprecate this API when issue 2706 is fixed. |
+@deprecated |
Function protectAsync0(Function callback, {String id}) { |
- return new _SpreadArgsHelper(callback, 0, -1, null, id).invoke0; |
+ return callback; |
} |
/** |
- * Like [protectAsync0] but [callback] should take 1 positional argument. |
+ * *Deprecated* |
+ * |
+ * All tests are now run an isolated [Zone]. |
+ * |
+ * You can safely remove calls to this method. |
*/ |
-// TODO(sigmund): deprecate this API when issue 2706 is fixed. |
+@deprecated |
Function protectAsync1(Function callback, {String id}) { |
- return new _SpreadArgsHelper(callback, 0, -1, null, id).invoke1; |
+ return callback; |
} |
/** |
- * Like [protectAsync0] but [callback] should take 2 positional arguments. |
+ * *Deprecated* |
+ * |
+ * All tests are now run an isolated [Zone]. |
+ * |
+ * You can safely remove calls to this method. |
*/ |
-// TODO(sigmund): deprecate this API when issue 2706 is fixed. |
+@deprecated |
Function protectAsync2(Function callback, {String id}) { |
- return new _SpreadArgsHelper(callback, 0, -1, null, id).invoke2; |
+ return callback; |
} |
/** |
@@ -483,12 +484,6 @@ void handleExternalError(e, String message, [stack]) { |
} |
} |
-void rerunTests() { |
- _uncaughtErrorMessage = null; |
- _initialized = true; // We don't want to reset the test array. |
- runTests(); |
-} |
- |
/** |
* Filter the tests. [testFilter] can be a [RegExp], a [String] or a |
* predicate function. This is different to enabling/disabling tests |
@@ -517,24 +512,15 @@ void runTests() { |
} |
/** |
- * Run [tryBody] guarded in a try-catch block. If an exception is thrown, it is |
- * passed to the corresponding test. |
+ * *Deprecated* |
+ * |
+ * All tests are now run an isolated [Zone]. |
* |
- * The value returned by [tryBody] (if any) is returned by [guardAsync]. |
+ * You can safely remove calls to this method. |
*/ |
+@deprecated |
guardAsync(Function tryBody) { |
- return _guardAsync(tryBody, null, currentTestCase); |
-} |
- |
-_guardAsync(Function tryBody, Function finallyBody, TestCase testCase) { |
- assert(testCase != null); |
- try { |
- return tryBody(); |
- } catch (e, trace) { |
- _registerException(testCase, e, trace); |
- } finally { |
- if (finallyBody != null) finallyBody(); |
- } |
+ return tryBody(); |
} |
/** |
@@ -565,7 +551,12 @@ void _runTest() { |
_completeTests(); |
} else { |
var testCase = testCases[_currentTestCaseIndex]; |
- Future f = _guardAsync(testCase._run, null, testCase); |
+ Future f = runZoned(testCase._run, onError: (error, stack) { |
+ // TODO(kevmoo) Do a better job of flagging these are async errors. |
+ // https://code.google.com/p/dart/issues/detail?id=16530 |
+ _registerException(testCase, error, stack); |
+ }); |
+ |
var timeout = unittestConfiguration.timeout; |
Timer timer; |