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

Unified Diff: tests/corelib/src/FuturesTest.dart

Issue 9108010: Futures.wait should call then, even if some(or all) of the futures are done (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 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
« corelib/src/future.dart ('K') | « corelib/src/future.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/src/FuturesTest.dart
===================================================================
--- tests/corelib/src/FuturesTest.dart (revision 0)
+++ tests/corelib/src/FuturesTest.dart (revision 0)
@@ -0,0 +1,41 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+Future testWaitEmpty() {
+ List<Future> futures = new List<Future>();
+ return Futures.wait(futures);
+}
+
+Future testCompleteAfterWait() {
+ List<Future> futures = new List<Future>();
+ Completer<Object> c = new Completer<Object>();
+ futures.add(c.future);
+ Future future = Futures.wait(futures);
+ c.complete(null);
+ return future;
+}
+
+Future testCompleteBeforeWait() {
+ List<Future> futures = new List<Future>();
+ Completer c = new Completer();
+ futures.add(c.future);
+ c.complete(null);
+ return Futures.wait(futures);
+}
+
+main() {
+ List<Future> futures = new List<Future>();
+
+ futures.add(testWaitEmpty());
+ futures.add(testCompleteAfterWait());
+ futures.add(testCompleteBeforeWait());
+
+ // Use a receive port for blocking the test.
+ // Note that if the test fails, the program will not end.
+ ReceivePort port = new ReceivePort();
+ Futures.wait(futures).then((List list) {
+ Expect.equals(3, list.length);
+ port.close();
+ });
+}
« corelib/src/future.dart ('K') | « corelib/src/future.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698