| 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 futures_test; | 5 library futures_test; |
| 6 import 'package:async_helper/async_helper.dart'; |
| 6 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 7 import 'dart:async'; | 8 import 'dart:async'; |
| 8 import 'dart:isolate'; | |
| 9 | 9 |
| 10 Future testWaitEmpty() { | 10 Future testWaitEmpty() { |
| 11 List<Future> futures = new List<Future>(); | 11 List<Future> futures = new List<Future>(); |
| 12 return Future.wait(futures); | 12 return Future.wait(futures); |
| 13 } | 13 } |
| 14 | 14 |
| 15 Future testCompleteAfterWait() { | 15 Future testCompleteAfterWait() { |
| 16 List<Future> futures = new List<Future>(); | 16 List<Future> futures = new List<Future>(); |
| 17 Completer<Object> c = new Completer<Object>(); | 17 Completer<Object> c = new Completer<Object>(); |
| 18 futures.add(c.future); | 18 futures.add(c.future); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 futures.add(testWaitEmpty()); | 107 futures.add(testWaitEmpty()); |
| 108 futures.add(testCompleteAfterWait()); | 108 futures.add(testCompleteAfterWait()); |
| 109 futures.add(testCompleteBeforeWait()); | 109 futures.add(testCompleteBeforeWait()); |
| 110 futures.add(testWaitWithMultipleValues()); | 110 futures.add(testWaitWithMultipleValues()); |
| 111 futures.add(testWaitWithSingleError()); | 111 futures.add(testWaitWithSingleError()); |
| 112 futures.add(testWaitWithMultipleErrors()); | 112 futures.add(testWaitWithMultipleErrors()); |
| 113 futures.add(testForEachEmpty()); | 113 futures.add(testForEachEmpty()); |
| 114 futures.add(testForEach()); | 114 futures.add(testForEach()); |
| 115 futures.add(testForEachWithException()); | 115 futures.add(testForEachWithException()); |
| 116 | 116 |
| 117 // Use a receive port for blocking the test. | 117 asyncStart(); |
| 118 // Note that if the test fails, the program will not end. | |
| 119 ReceivePort port = new ReceivePort(); | |
| 120 Future.wait(futures).then((List list) { | 118 Future.wait(futures).then((List list) { |
| 121 Expect.equals(9, list.length); | 119 Expect.equals(9, list.length); |
| 122 port.close(); | 120 asyncEnd(); |
| 123 }); | 121 }); |
| 124 } | 122 } |
| OLD | NEW |