Chromium Code Reviews| Index: tests/corelib/future_test.dart |
| =================================================================== |
| --- tests/corelib/future_test.dart (revision 8478) |
| +++ tests/corelib/future_test.dart (working copy) |
| @@ -389,58 +389,11 @@ |
| final error = new Exception("Oh no!"); |
| final transformedFuture = completer.future.transform((x) { throw error; }); |
| Expect.isFalse(transformedFuture.isComplete); |
| - completer.complete("42"); |
| + transformedFuture.then((v) => null); |
| + Expect.throws(() => completer.complete("42"), check: (e) => e == error); |
|
sammccall
2012/06/10 22:18:09
This covers bug 3489
|
| Expect.equals(error, transformedFuture.exception); |
| } |
| -// Tests [handleException] and [transform] on the same Future. |
| -// An earlier implementation of [transform] didn't support this, and behavior |
| -// depended on whether [handleException] or [transform] was called first. |
| - |
| -testTransformAndHandleException() { |
| - final completer = new Completer<String>(); |
| - final error = new Exception("Oh no!"); |
| - var futureError; |
| - var transformedFutureError; |
| - |
| - completer.future.transform((x) => "** $x **").handleException((e) { |
| - Expect.isNotNull(futureError); |
| - transformedFutureError = e; |
| - return true; |
| - }); |
| - completer.future.handleException((e) { |
| - Expect.isNull(transformedFutureError); |
| - futureError = e; |
| - return true; |
| - }); |
| - completer.completeException(error); |
| - |
| - Expect.equals(error, futureError); |
| - Expect.equals(error, transformedFutureError); |
| -} |
| - |
| -testHandleExceptionAndTransform() { |
| - final completer = new Completer<String>(); |
| - final error = new Exception("Oh no!"); |
| - var futureError; |
| - var transformedFutureError; |
| - |
| - completer.future.handleException((e) { |
| - Expect.isNull(transformedFutureError); |
| - futureError = e; |
| - return true; |
| - }); |
| - completer.future.transform((x) => "** $x **").handleException((e) { |
| - Expect.isNotNull(futureError); |
| - transformedFutureError = e; |
| - return true; |
| - }); |
| - completer.completeException(error); |
| - |
| - Expect.equals(error, futureError); |
| - Expect.equals(error, transformedFutureError); |
| -} |
| - |
| // Tests for Future.chain |
| testChainSuccess() { |
| @@ -475,8 +428,9 @@ |
| Expect.equals("42", x); |
| throw error; |
| }); |
| + chainedFuture.then((v) => null); |
| Expect.isFalse(chainedFuture.isComplete); |
| - completerA.complete("42"); |
| + Expect.throws(() => completerA.complete("42"), check: (e) => e == error); |
| Expect.equals(error, chainedFuture.exception); |
| } |
| @@ -495,58 +449,6 @@ |
| Expect.equals(error, chainedFuture.exception); |
| } |
| -// Tests [handleException] and [chain] on the same Future. |
| -// An earlier implementation of [chain] didn't support this, and behavior |
| -// depended on whether [handleException] or [chain] was called first. |
| - |
| -testChainAndHandleException() { |
| - final completer = new Completer<String>(); |
| - final error = new Exception("Oh no!"); |
| - var futureError; |
| - var chainedFutureError; |
| - |
| - var chainedFuture = completer.future |
| - .chain((_) => new Future<int>.immediate(43)); |
| - chainedFuture.handleException((e) { |
| - Expect.isNotNull(futureError); |
| - chainedFutureError = e; |
| - return true; |
| - }); |
| - completer.future.handleException((e) { |
| - Expect.isNull(chainedFutureError); |
| - futureError = e; |
| - return true; |
| - }); |
| - completer.completeException(error); |
| - |
| - Expect.equals(error, futureError); |
| - Expect.equals(error, chainedFutureError); |
| -} |
| - |
| -testHandleExceptionAndChain() { |
| - final completer = new Completer<String>(); |
| - final error = new Exception("Oh no!"); |
| - var futureError; |
| - var chainedFutureError; |
| - |
| - completer.future.handleException((e) { |
| - Expect.isNull(chainedFutureError); |
| - futureError = e; |
| - return true; |
| - }); |
| - var chainedFuture = completer.future |
| - .chain((_) => new Future<int>.immediate(43)); |
| - chainedFuture.handleException((e) { |
| - Expect.isNotNull(futureError); |
| - chainedFutureError = e; |
| - return true; |
| - }); |
| - completer.completeException(error); |
| - |
| - Expect.equals(error, futureError); |
| - Expect.equals(error, chainedFutureError); |
| -} |
| - |
| main() { |
| testImmediate(); |
| testNeverComplete(); |
| @@ -574,12 +476,8 @@ |
| testTransformSuccess(); |
| testTransformFutureFails(); |
| testTransformTransformerFails(); |
| - testTransformAndHandleException(); |
| - testHandleExceptionAndTransform(); |
| testChainSuccess(); |
| testChainFirstFutureFails(); |
| testChainTransformerFails(); |
| testChainSecondFutureFails(); |
| - testChainAndHandleException(); |
| - testHandleExceptionAndChain(); |
| } |