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

Side by Side Diff: tests/lib/async/futures_test.dart

Issue 68523005: Make Future.wait have an eagerError option that defaults to false. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Combine two versions. Improve error handling. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« sdk/lib/async/future.dart ('K') | « sdk/lib/async/future.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:async_helper/async_helper.dart';
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 Future testWaitEmpty() { 10 Future testWaitEmpty() {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 c2.completeError('incorrect error 1'); 112 c2.completeError('incorrect error 1');
113 113
114 return Future.wait(futures).then((_) { 114 return Future.wait(futures).then((_) {
115 throw 'incorrect error 2'; 115 throw 'incorrect error 2';
116 }).catchError((error, stackTrace) { 116 }).catchError((error, stackTrace) {
117 Expect.equals('correct error', error); 117 Expect.equals('correct error', error);
118 Expect.isNotNull(stackTrace); 118 Expect.isNotNull(stackTrace);
119 }); 119 });
120 } 120 }
121 121
122 Future testEagerWait() {
floitsch 2013/11/19 10:50:34 test not called.
Lasse Reichstein Nielsen 2013/11/20 09:29:28 Whoops. Fixed.
123 Completer c1 = new Completer();
124 Completer c2 = new Completer();
125 List<Future> futures = <Future>[c1.future, c2.future];
126 Future waited = Future.wait(futures, eagerError: true);
127 var result = waited.then((v) { throw "should not be called"; },
128 onError: (e, s) {
floitsch 2013/11/19 10:50:34 also test that stack trace is passed through.
Lasse Reichstein Nielsen 2013/11/20 09:29:28 Will do.
129 Expect.equals(e, 42);
130 returntrue;
floitsch 2013/11/19 10:50:34 return true
Lasse Reichstein Nielsen 2013/11/20 09:29:28 Quite obvious that it isn't called too. :(
131 });
132 c1.completeError(42);
133 return result;
134 }
135
122 Future testForEachEmpty() { 136 Future testForEachEmpty() {
123 return Future.forEach([], (_) { 137 return Future.forEach([], (_) {
124 throw 'should not be called'; 138 throw 'should not be called';
125 }); 139 });
126 } 140 }
127 141
128 Future testForEach() { 142 Future testForEach() {
129 var seen = <int>[]; 143 var seen = <int>[];
130 return Future.forEach([1, 2, 3, 4, 5], (n) { 144 return Future.forEach([1, 2, 3, 4, 5], (n) {
131 seen.add(n); 145 seen.add(n);
(...skipping 28 matching lines...) Expand all
160 futures.add(testForEachEmpty()); 174 futures.add(testForEachEmpty());
161 futures.add(testForEach()); 175 futures.add(testForEach());
162 futures.add(testForEachWithException()); 176 futures.add(testForEachWithException());
163 177
164 asyncStart(); 178 asyncStart();
165 Future.wait(futures).then((List list) { 179 Future.wait(futures).then((List list) {
166 Expect.equals(11, list.length); 180 Expect.equals(11, list.length);
167 asyncEnd(); 181 asyncEnd();
168 }); 182 });
169 } 183 }
OLDNEW
« sdk/lib/async/future.dart ('K') | « sdk/lib/async/future.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698