OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #library("FuturesTest"); | 5 library futures_test; |
6 #import("dart:isolate"); | 6 import 'dart:isolate'; |
7 | 7 |
8 Future testWaitEmpty() { | 8 Future testWaitEmpty() { |
9 List<Future> futures = new List<Future>(); | 9 List<Future> futures = new List<Future>(); |
10 return Futures.wait(futures); | 10 return Futures.wait(futures); |
11 } | 11 } |
12 | 12 |
13 Future testCompleteAfterWait() { | 13 Future testCompleteAfterWait() { |
14 List<Future> futures = new List<Future>(); | 14 List<Future> futures = new List<Future>(); |
15 Completer<Object> c = new Completer<Object>(); | 15 Completer<Object> c = new Completer<Object>(); |
16 futures.add(c.future); | 16 futures.add(c.future); |
(...skipping 18 matching lines...) Expand all Loading... |
35 futures.add(testCompleteBeforeWait()); | 35 futures.add(testCompleteBeforeWait()); |
36 | 36 |
37 // Use a receive port for blocking the test. | 37 // Use a receive port for blocking the test. |
38 // Note that if the test fails, the program will not end. | 38 // Note that if the test fails, the program will not end. |
39 ReceivePort port = new ReceivePort(); | 39 ReceivePort port = new ReceivePort(); |
40 Futures.wait(futures).then((List list) { | 40 Futures.wait(futures).then((List list) { |
41 Expect.equals(3, list.length); | 41 Expect.equals(3, list.length); |
42 port.close(); | 42 port.close(); |
43 }); | 43 }); |
44 } | 44 } |
OLD | NEW |