Index: tests/lib/async/future_test.dart |
diff --git a/tests/lib/async/future_test.dart b/tests/lib/async/future_test.dart |
index 030340d6468ed9686aee59e2df9a672c5f35a050..e8387bfd19e1a159fbda3c9c6f5e508b44d668ce 100644 |
--- a/tests/lib/async/future_test.dart |
+++ b/tests/lib/async/future_test.dart |
@@ -926,6 +926,74 @@ void testTypes() { |
testType("Future.error", new Future<int>.error("ERR")..catchError((_){})); |
} |
+void testAnyValue() { |
+ asyncStart(); |
+ var cs = new List.generate(3, (_) => new Completer()); |
+ var result = Future.any(cs.map((x) => x.future)); |
+ |
+ result.then((v) { |
+ Expect.equals(42, v); |
+ asyncEnd(); |
+ }, onError: (e, s) { |
+ Expect.fail("Unexpected error: $e"); |
+ }); |
+ |
+ cs[1].complete(42); |
+ cs[2].complete(10); |
+ cs[0].complete(20); |
+} |
+ |
+void testAnyError() { |
+ asyncStart(); |
+ var cs = new List.generate(3, (_) => new Completer()); |
+ var result = Future.any(cs.map((x) => x.future)); |
+ |
+ result.then((v) { |
+ Expect.fail("Unexpected value: $v"); |
+ }, onError: (e, s) { |
+ Expect.equals(42, e); |
+ asyncEnd(); |
+ }); |
+ |
+ cs[1].completeError(42); |
+ cs[2].complete(10); |
+ cs[0].complete(20); |
+} |
+ |
+void testAnyIgnoreIncomplete() { |
+ asyncStart(); |
+ var cs = new List.generate(3, (_) => new Completer()); |
+ var result = Future.any(cs.map((x) => x.future)); |
+ |
+ result.then((v) { |
+ Expect.equals(42, v); |
+ asyncEnd(); |
+ }, onError: (e, s) { |
+ Expect.fail("Unexpected error: $e"); |
+ }); |
+ |
+ cs[1].complete(42); |
+ // The other two futures never complete. |
+} |
+ |
+void testAnyIgnoreError() { |
+ asyncStart(); |
+ var cs = new List.generate(3, (_) => new Completer()); |
+ var result = Future.any(cs.map((x) => x.future)); |
+ |
+ result.then((v) { |
+ Expect.equals(42, v); |
+ asyncEnd(); |
+ }, onError: (e, s) { |
+ Expect.fail("Unexpected error: $e"); |
+ }); |
+ |
+ cs[1].complete(42); |
+ // The errors are ignored, not uncaught. |
+ cs[2].completeError("BAD"); |
+ cs[0].completeError("BAD"); |
+} |
+ |
main() { |
asyncStart(); |
@@ -989,6 +1057,11 @@ main() { |
testTypes(); |
+ testAnyValue(); |
+ testAnyError(); |
+ testAnyIgnoreIncomplete(); |
+ testAnyIgnoreError(); |
+ |
asyncEnd(); |
} |