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

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

Issue 56123012: Propagate stack trace when using Future.wait. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test and actually run it. 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 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 936c5187d1f613739073200c8d014165e8ca81c7..9b7f00a4914a16c5ca9fed3c7f75a4be0e16191d 100644
--- a/tests/lib/async/futures_test.dart
+++ b/tests/lib/async/futures_test.dart
@@ -53,8 +53,9 @@ Future testWaitWithSingleError() {
return Future.wait(futures).then((_) {
throw 'incorrect error';
- }).catchError((error) {
+ }).catchError((error, stackTrace) {
Expect.equals('correct error', error);
+ Expect.isNull(stackTrace);
});
}
@@ -69,8 +70,52 @@ Future testWaitWithMultipleErrors() {
return Future.wait(futures).then((_) {
throw 'incorrect error 2';
- }).catchError((error) {
+ }).catchError((error, stackTrace) {
+ Expect.equals('correct error', error);
+ Expect.isNull(stackTrace);
+ });
+}
+
+StackTrace get currentStackTrace {
+ try {
+ throw 0;
+ } catch(e, st) {
+ return st;
+ }
+ return null;
+}
+
+Future testWaitWithSingleErrorWithStackTrace() {
+ List<Future> futures = new List<Future>();
+ Completer c1 = new Completer();
+ Completer c2 = new Completer();
+ futures.add(c1.future);
+ futures.add(c2.future);
+ c1.complete();
+ c2.completeError('correct error', currentStackTrace);
+
+ return Future.wait(futures).then((_) {
+ throw 'incorrect error';
+ }).catchError((error, stackTrace) {
+ Expect.equals('correct error', error);
+ Expect.isNotNull(stackTrace);
+ });
+}
+
+Future testWaitWithMultipleErrorsWithStackTrace() {
+ List<Future> futures = new List<Future>();
+ Completer c1 = new Completer();
+ Completer c2 = new Completer();
+ futures.add(c1.future);
+ futures.add(c2.future);
+ c1.completeError('correct error', currentStackTrace);
+ c2.completeError('incorrect error 1');
+
+ return Future.wait(futures).then((_) {
+ throw 'incorrect error 2';
+ }).catchError((error, stackTrace) {
Expect.equals('correct error', error);
+ Expect.isNotNull(stackTrace);
});
}
@@ -110,13 +155,15 @@ main() {
futures.add(testWaitWithMultipleValues());
futures.add(testWaitWithSingleError());
futures.add(testWaitWithMultipleErrors());
+ futures.add(testWaitWithSingleErrorWithStackTrace());
+ futures.add(testWaitWithMultipleErrorsWithStackTrace());
futures.add(testForEachEmpty());
futures.add(testForEach());
futures.add(testForEachWithException());
asyncStart();
Future.wait(futures).then((List list) {
- Expect.equals(9, list.length);
+ Expect.equals(11, 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