Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: tests/lib/async/futures_test.dart

Issue 2853203002: Change Future.doWhile to use a loop for non-future results instead of recursion. (Closed)
Patch Set: Address comment. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/async/future.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/futures_test.dart
diff --git a/tests/lib/async/futures_test.dart b/tests/lib/async/futures_test.dart
index a9a37e0df3246392a75b586ae123f54ba9fc8f3f..5f3b532173a128480019734ef1ada507cdf2b34e 100644
--- a/tests/lib/async/futures_test.dart
+++ b/tests/lib/async/futures_test.dart
@@ -238,6 +238,30 @@ Future testDoWhileWithException() {
});
}
+Future testDoWhileManyFutures() {
+ int n = 100000;
+ var ftrue = new Future.value(false);
+ var ffalse = new Future.value(false);
+ return Future.doWhile(() {
+ return (--n > 0) ? ftrue : ffalse;
+ }).then((_) {
+ // Success
+ }, onError: (e, s) {
+ Expect.fail("$e\n$s");
+ });
+}
+
+Future testDoWhileManyValues() {
+ int n = 100000;
+ return Future.doWhile(() {
+ return (--n > 0);
+ }).then((_) {
+ // Success
+ }, onError: (e, s) {
+ Expect.fail("$e\n$s");
+ });
+}
+
main() {
List<Future> futures = new List<Future>();
@@ -259,10 +283,12 @@ main() {
futures.add(testDoWhile());
futures.add(testDoWhileSync());
futures.add(testDoWhileWithException());
+ futures.add(testDoWhileManyFutures());
+ futures.add(testDoWhileManyValues());
asyncStart();
Future.wait(futures).then((List list) {
- Expect.equals(18, list.length);
+ Expect.equals(20, list.length);
asyncEnd();
});
}
« no previous file with comments | « sdk/lib/async/future.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698