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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « corelib/src/future.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 class FuturesTest {
6 static void testMain() {
7 List<Future> futures = new List<Future>();
8
9 futures.add(testWaitEmpty());
10 futures.add(testCompleteAfterWait());
11 futures.add(testCompleteBeforeWait());
12
13 // Use a receive port for blocking the test.
14 // Note that if the test fails, the program will not end.
15 ReceivePort port = new ReceivePort();
16 Futures.wait(futures).then((List list) {
17 Expect.equals(list.length, 3);
kasperl 2012/01/06 09:06:46 Weird indentation. Emacs user?
kasperl 2012/01/06 09:06:46 Expect.equals(3, list.length) -- expectation, actu
Anders Johnsen 2012/01/06 09:28:33 Vim, fixed :)
18 port.close();
19 });
20 }
21
22 static void testWaitEmpty() {
kasperl 2012/01/06 09:06:46 Your void methods return values. Seems wrong.
Anders Johnsen 2012/01/06 09:28:33 Done.
23 List<Future> futures = new List<Future>();
24
25 return Futures.wait(futures);
26 }
27
28 static void testCompleteAfterWait() {
29 List<Future> futures = new List<Future>();
30 Completer<Object> c = new Completer<Object>();
31 futures.add(c.future);
32
kasperl 2012/01/06 09:06:46 I would use less newlines here.
Anders Johnsen 2012/01/06 09:28:33 Done.
33 Future future = Futures.wait(futures);
34
35 c.complete(null);
36
37 return future;
38 }
39
40 static void testCompleteBeforeWait() {
41 List<Future> futures = new List<Future>();
42 Completer c = new Completer();
43 futures.add(c.future);
44
kasperl 2012/01/06 09:06:46 .. and here.
Anders Johnsen 2012/01/06 09:28:33 Done.
45 c.complete(null);
46
47 return Futures.wait(futures);
48 }
49 }
50
51 main() {
52 FuturesTest.testMain();
kasperl 2012/01/06 09:06:46 Maybe this would actually be nicer without the cla
Anders Johnsen 2012/01/06 09:28:33 Yeah, but using a class with static members follow
53 }
OLDNEW
« no previous file with comments | « corelib/src/future.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698