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

Side by Side Diff: lib/unittest/core_matchers.dart

Issue 10766006: Print the stack traces for Future expectations that raise exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/unittest/future_matchers.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 5
6 /** 6 /**
7 * Returns a matcher that matches empty strings, maps or collections. 7 * Returns a matcher that matches empty strings, maps or collections.
8 */ 8 */
9 final Matcher isEmpty = const _Empty(); 9 final Matcher isEmpty = const _Empty();
10 10
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 bool matches(item) { 274 bool matches(item) {
275 if (item is Future) { 275 if (item is Future) {
276 // Queue up an asynchronous expectation that validates when the future 276 // Queue up an asynchronous expectation that validates when the future
277 // completes. 277 // completes.
278 item.onComplete(expectAsync1((future) { 278 item.onComplete(expectAsync1((future) {
279 if (future.hasValue) { 279 if (future.hasValue) {
280 expect(false, reason: 280 expect(false, reason:
281 "Expected future to fail, but succeeded with '${future.value}'."); 281 "Expected future to fail, but succeeded with '${future.value}'.");
282 } else if (_matcher != null) { 282 } else if (_matcher != null) {
283 expect(future.exception, _matcher); 283 var reason;
284 if (future.stackTrace != null) {
285 var stackTrace = future.stackTrace.toString();
286 stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}";
287 reason = "Actual exception trace:\n$stackTrace";
288 }
289 expect(future.exception, _matcher, reason: reason);
284 } 290 }
285 })); 291 }));
286 292
287 // It hasn't failed yet. 293 // It hasn't failed yet.
288 return true; 294 return true;
289 } 295 }
290 296
291 try { 297 try {
292 item(); 298 item();
293 return false; 299 return false;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 final _matcher; 587 final _matcher;
582 final String _description; 588 final String _description;
583 589
584 const _Predicate(this._matcher, this._description); 590 const _Predicate(this._matcher, this._description);
585 591
586 bool matches(item) => _matcher(item); 592 bool matches(item) => _matcher(item);
587 593
588 Description describe(Description description) => 594 Description describe(Description description) =>
589 description.add(_description); 595 description.add(_description);
590 } 596 }
OLDNEW
« no previous file with comments | « no previous file | lib/unittest/future_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698