Chromium Code Reviews| 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..c703780ebfcc35311bf89c10993af126e26786ff 100644 |
| --- a/tests/lib/async/futures_test.dart |
| +++ b/tests/lib/async/futures_test.dart |
| @@ -184,6 +184,14 @@ Future testForEach() { |
| }).then((_) => Expect.listEquals([1, 2, 3, 4, 5], seen)); |
| } |
| +Future testForEachSync() { |
| + var seen = <int>[]; |
| + return Future.forEach([1, 2, 3, 4, 5], (n) { |
| + seen.add(n); |
| + return; |
| + }).then((_) => Expect.listEquals([1, 2, 3, 4, 5], seen)); |
|
Lasse Reichstein Nielsen
2014/06/26 06:26:49
The entire "(n) { seen.add(n); return; }" function
nweiz
2014/06/26 19:48:11
Done.
|
| +} |
| + |
| Future testForEachWithException() { |
| var seen = <int>[]; |
| return Future.forEach([1, 2, 3, 4, 5], (n) { |
| @@ -197,6 +205,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,7 +250,11 @@ 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) { |