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

Unified Diff: tests/corelib/future_test.dart

Issue 10537096: Revert changes to Future.chain() and Future.transform() from http://codereview.chromium.org/10517006 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « corelib/src/implementation/future_implementation.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « corelib/src/implementation/future_implementation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698