| Index: tests/lib/async/futures_test.dart
|
| diff --git a/tests/lib/async/futures_test.dart b/tests/lib/async/futures_test.dart
|
| index 21121206d4469e4297f68fd4d81b19d554f89b2f..6d6037216719ce8f0dbf952963710aa036a9e0f3 100644
|
| --- a/tests/lib/async/futures_test.dart
|
| +++ b/tests/lib/async/futures_test.dart
|
| @@ -184,6 +184,12 @@ Future testForEach() {
|
| }).then((_) => Expect.listEquals([1, 2, 3, 4, 5], seen));
|
| }
|
|
|
| +Future testForEachSync() {
|
| + var seen = <int>[];
|
| + return Future.forEach([1, 2, 3, 4, 5], seen.add)
|
| + .then((_) => Expect.listEquals([1, 2, 3, 4, 5], seen));
|
| +}
|
| +
|
| Future testForEachWithException() {
|
| var seen = <int>[];
|
| return Future.forEach([1, 2, 3, 4, 5], (n) {
|
| @@ -197,6 +203,35 @@ Future testForEachWithException() {
|
| });
|
| }
|
|
|
| +Future testDoWhile() {
|
| + var count = 0;
|
| + return Future.doWhile(() {
|
| + count++;
|
| + return new Future(() => count < 10);
|
| + }).then((_) => Expect.equals(10, count));
|
| +}
|
| +
|
| +Future testDoWhileSync() {
|
| + var count = 0;
|
| + return Future.doWhile(() {
|
| + count++;
|
| + return count < 10;
|
| + }).then((_) => Expect.equals(10, count));
|
| +}
|
| +
|
| +Future testDoWhileWithException() {
|
| + var count = 0;
|
| + return Future.doWhile(() {
|
| + count++;
|
| + if (count == 4) throw 'correct exception';
|
| + return new Future(() => true);
|
| + }).then((_) {
|
| + throw 'incorrect exception';
|
| + }).catchError((error) {
|
| + Expect.equals('correct exception', error);
|
| + });
|
| +}
|
| +
|
| main() {
|
| List<Future> futures = new List<Future>();
|
|
|
| @@ -213,11 +248,15 @@ main() {
|
| futures.add(testEagerWait());
|
| futures.add(testForEachEmpty());
|
| futures.add(testForEach());
|
| + futures.add(testForEachSync());
|
| futures.add(testForEachWithException());
|
| + futures.add(testDoWhile());
|
| + futures.add(testDoWhileSync());
|
| + futures.add(testDoWhileWithException());
|
|
|
| asyncStart();
|
| Future.wait(futures).then((List list) {
|
| - Expect.equals(14, list.length);
|
| + Expect.equals(18, list.length);
|
| asyncEnd();
|
| });
|
| }
|
|
|