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

Side by Side 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: 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
« no previous file with comments | « 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 List<Future> futures = new List<Future>(); 46 List<Future> futures = new List<Future>();
47 Completer c1 = new Completer(); 47 Completer c1 = new Completer();
48 Completer c2 = new Completer(); 48 Completer c2 = new Completer();
49 futures.add(c1.future); 49 futures.add(c1.future);
50 futures.add(c2.future); 50 futures.add(c2.future);
51 c1.complete(); 51 c1.complete();
52 c2.completeError('correct error'); 52 c2.completeError('correct error');
53 53
54 return Future.wait(futures).then((_) { 54 return Future.wait(futures).then((_) {
55 throw 'incorrect error'; 55 throw 'incorrect error';
56 }).catchError((error) { 56 }).catchError((error, stackTrace) {
57 Expect.equals('correct error', error); 57 Expect.equals('correct error', error);
58 Expect.isNull(stackTrace);
58 }); 59 });
59 } 60 }
60 61
61 Future testWaitWithMultipleErrors() { 62 Future testWaitWithMultipleErrors() {
62 List<Future> futures = new List<Future>(); 63 List<Future> futures = new List<Future>();
63 Completer c1 = new Completer(); 64 Completer c1 = new Completer();
64 Completer c2 = new Completer(); 65 Completer c2 = new Completer();
65 futures.add(c1.future); 66 futures.add(c1.future);
66 futures.add(c2.future); 67 futures.add(c2.future);
67 c1.completeError('correct error'); 68 c1.completeError('correct error');
68 c2.completeError('incorrect error 1'); 69 c2.completeError('incorrect error 1');
69 70
70 return Future.wait(futures).then((_) { 71 return Future.wait(futures).then((_) {
71 throw 'incorrect error 2'; 72 throw 'incorrect error 2';
72 }).catchError((error) { 73 }).catchError((error, stackTrace) {
73 Expect.equals('correct error', error); 74 Expect.equals('correct error', error);
75 Expect.isNull(stackTrace);
74 }); 76 });
75 } 77 }
76 78
79 StackTrace get currentStackTrace {
80 try {
81 throw 0;
82 } catch(e, st) {
83 return st;
84 }
85 return null;
86 }
87
88 Future testWaitWithSingleErrorWithStackTrace() {
89 List<Future> futures = new List<Future>();
90 Completer c1 = new Completer();
91 Completer c2 = new Completer();
92 futures.add(c1.future);
93 futures.add(c2.future);
94 c1.complete();
95 c2.completeError('correct error', currentStackTrace);
96
97 return Future.wait(futures).then((_) {
98 throw 'incorrect error';
99 }).catchError((error, stackTrace) {
100 Expect.equals('correct error', error);
101 Expect.isNull(stackTrace);
Anders Johnsen 2013/11/05 10:21:21 isNotNull?
floitsch 2013/11/05 18:42:12 Done.
102 });
103 }
104
105 Future testWaitWithMultipleErrorsWithStackTrace() {
106 List<Future> futures = new List<Future>();
107 Completer c1 = new Completer();
108 Completer c2 = new Completer();
109 futures.add(c1.future);
110 futures.add(c2.future);
111 c1.completeError('correct error', currentStackTrace);
112 c2.completeError('incorrect error 1');
113
114 return Future.wait(futures).then((_) {
115 throw 'incorrect error 2';
116 }).catchError((error, stackTrace) {
117 Expect.equals('correct error', error);
118 Expect.isNotNull(stackTrace);
119 });
120 }
121
77 Future testForEachEmpty() { 122 Future testForEachEmpty() {
78 return Future.forEach([], (_) { 123 return Future.forEach([], (_) {
79 throw 'should not be called'; 124 throw 'should not be called';
80 }); 125 });
81 } 126 }
82 127
83 Future testForEach() { 128 Future testForEach() {
84 var seen = <int>[]; 129 var seen = <int>[];
85 return Future.forEach([1, 2, 3, 4, 5], (n) { 130 return Future.forEach([1, 2, 3, 4, 5], (n) {
86 seen.add(n); 131 seen.add(n);
(...skipping 26 matching lines...) Expand all
113 futures.add(testForEachEmpty()); 158 futures.add(testForEachEmpty());
114 futures.add(testForEach()); 159 futures.add(testForEach());
115 futures.add(testForEachWithException()); 160 futures.add(testForEachWithException());
116 161
117 asyncStart(); 162 asyncStart();
118 Future.wait(futures).then((List list) { 163 Future.wait(futures).then((List list) {
119 Expect.equals(9, list.length); 164 Expect.equals(9, list.length);
120 asyncEnd(); 165 asyncEnd();
121 }); 166 });
122 } 167 }
OLDNEW
« 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