Chromium Code Reviews| Index: pkg/unittest/lib/unittest.dart |
| diff --git a/pkg/unittest/lib/unittest.dart b/pkg/unittest/lib/unittest.dart |
| index 57f25812c9f8edabc456c86639fc31b0891ea391..8c3ea02b005ca6eddce3257dc81ec89146ce6544 100644 |
| --- a/pkg/unittest/lib/unittest.dart |
| +++ b/pkg/unittest/lib/unittest.dart |
| @@ -371,33 +371,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; |
|
Siggi Cherem (dart-lang)
2014/02/04 02:20:05
not sure if this works. runZoned only intercepts 0
kevmoo
2014/02/04 02:26:18
This is basically a no-op. The assumption is that
nweiz
2014/02/04 02:34:26
I don't think this is accurate. All asynchronous c
Siggi Cherem (dart-lang)
2014/02/04 02:42:01
To clarify what my worry was. Zones used to only h
kevmoo
2014/02/04 02:45:28
I'm not sure how Zones handle callbacks with N arg
|
| } |
| /** |
| @@ -517,24 +523,15 @@ void runTests() { |
| } |
| /** |
| - * Run [tryBody] guarded in a try-catch block. If an exception is thrown, it is |
| - * passed to the corresponding test. |
| + * *Deprecated* |
| * |
| - * The value returned by [tryBody] (if any) is returned by [guardAsync]. |
| + * All tests are now run an isolated [Zone]. |
| + * |
| + * 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 +562,10 @@ void _runTest() { |
| _completeTests(); |
| } else { |
| var testCase = testCases[_currentTestCaseIndex]; |
| - Future f = _guardAsync(testCase._run, null, testCase); |
| + Future f = runZoned(testCase._run, onError: (error, stack) { |
| + _registerException(testCase, error, stack); |
| + }); |
| + |
| var timeout = unittestConfiguration.timeout; |
| Timer timer; |