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

Unified Diff: tests/lib/async/future_test.dart

Issue 12043013: Add regression-test for badly chained future-impementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/future_test.dart
diff --git a/tests/lib/async/future_test.dart b/tests/lib/async/future_test.dart
index f79c564d4326814b459dd2f8793681643308fbf3..b3a53c0e9ef1aaa0c6282eba5cebe39d880524c1 100644
--- a/tests/lib/async/future_test.dart
+++ b/tests/lib/async/future_test.dart
@@ -518,6 +518,45 @@ testCompleteWithAsyncError() {
completer.completeError(error);
}
+testChainedFutureValue() {
+ final completer = new Completer();
+ final future = completer.future;
+ var port = new ReceivePort();
+
+ future.then((v) => new Future.immediate(v * 2))
+ .then((v) {
+ Expect.equals(42, v);
Mads Ager (google) 2013/01/21 12:51:10 I would expect this to be indented one more space
Lasse Reichstein Nielsen 2013/01/21 13:09:39 unindented '}'.
+ port.close();
+ });
+ completer.complete(21);
+}
+
+testChainedFutureValueDelay() {
+ final completer = new Completer();
+ final future = completer.future;
+ var port = new ReceivePort();
+
+ future.then((v) => new Future.delayed(10, () => v * 2))
+ .then((v) {
+ Expect.equals(42, v);
+ port.close();
+ });
+ completer.complete(21);
+}
+
+testChainedFutureError() {
+ final completer = new Completer();
+ final future = completer.future;
+ var port = new ReceivePort();
+
+ future.then((v) => new Future.immediateError("Fehler"))
+ .then((v) { Expect.fail("unreachable!"); }, onError: (e) {
+ Expect.equals("Fehler", e.error);
+ port.close();
+ });
+ completer.complete(21);
+}
+
main() {
testImmediate();
testNeverComplete();
@@ -554,5 +593,9 @@ main() {
testFutureCatchThrowsAsync();
testFutureWhenThrowsAsync();
testFutureCatchRethrowsAsync();
+
+ testChainedFutureValue();
+ testChainedFutureValueDelay();
+ testChainedFutureError();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698