| OLD | NEW |
| (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 Future testWaitEmpty() { |
| 6 List<Future> futures = new List<Future>(); |
| 7 return Futures.wait(futures); |
| 8 } |
| 9 |
| 10 Future testCompleteAfterWait() { |
| 11 List<Future> futures = new List<Future>(); |
| 12 Completer<Object> c = new Completer<Object>(); |
| 13 futures.add(c.future); |
| 14 Future future = Futures.wait(futures); |
| 15 c.complete(null); |
| 16 return future; |
| 17 } |
| 18 |
| 19 Future testCompleteBeforeWait() { |
| 20 List<Future> futures = new List<Future>(); |
| 21 Completer c = new Completer(); |
| 22 futures.add(c.future); |
| 23 c.complete(null); |
| 24 return Futures.wait(futures); |
| 25 } |
| 26 |
| 27 main() { |
| 28 List<Future> futures = new List<Future>(); |
| 29 |
| 30 futures.add(testWaitEmpty()); |
| 31 futures.add(testCompleteAfterWait()); |
| 32 futures.add(testCompleteBeforeWait()); |
| 33 |
| 34 // Use a receive port for blocking the test. |
| 35 // Note that if the test fails, the program will not end. |
| 36 ReceivePort port = new ReceivePort(); |
| 37 Futures.wait(futures).then((List list) { |
| 38 Expect.equals(3, list.length); |
| 39 port.close(); |
| 40 }); |
| 41 } |
| OLD | NEW |