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

Unified Diff: pkg/unittest/lib/src/core_matchers.dart

Issue 11794041: Fix expect(future, throws). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes Created 7 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/core_matchers.dart
diff --git a/pkg/unittest/lib/src/core_matchers.dart b/pkg/unittest/lib/src/core_matchers.dart
index 74e8366b6276f7cfb521cf002bee095833a825e9..a9053a375cf3a18eeb35e0181d967d24a31af2d3 100644
--- a/pkg/unittest/lib/src/core_matchers.dart
+++ b/pkg/unittest/lib/src/core_matchers.dart
@@ -282,21 +282,21 @@ class Throws extends BaseMatcher {
bool matches(item, MatchState matchState) {
if (item is Future) {
+ var done = wrapAsync((fn) => fn());
+
// Queue up an asynchronous expectation that validates when the future
// completes.
- item.then(wrapAsync((value) {
- expect(false, isTrue, reason:
- "Expected future to fail, but succeeded with '$value'.");
- }));
-
- item.catchError((e) {
+ item.then((value) {
+ done(() => expect(false, isTrue, reason:
+ "Expected future to fail, but succeeded with '$value'."));
+ }, onError: (e) {
var reason;
if (e.stackTrace != null) {
var stackTrace = e.stackTrace.toString();
stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}";
reason = "Actual exception trace:\n$stackTrace";
}
- expect(e.error, _matcher, reason: reason);
+ done(() => expect(e.error, _matcher, reason: reason));
});
// It hasn't failed yet.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698