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

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

Issue 11821039: More fixes to unittest (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/future_matchers.dart
diff --git a/pkg/unittest/lib/src/future_matchers.dart b/pkg/unittest/lib/src/future_matchers.dart
index d757412b56cb3704d862a2b2335f4fc869687d0e..b04c07ac343daebfe92178704cd60015e76933e8 100644
--- a/pkg/unittest/lib/src/future_matchers.dart
+++ b/pkg/unittest/lib/src/future_matchers.dart
@@ -34,20 +34,19 @@ class _Completes extends BaseMatcher {
bool matches(item, MatchState matchState) {
if (item is! Future) return false;
+ var done = wrapAsync((fn) => fn());
- item.then(wrapAsync((value) {
- if (_matcher != null) expect(value, _matcher);
- }));
-
- item.catchError((e) {
+ item.then((value) {
+ done(() { if (_matcher != null) expect(value, _matcher); });
+ }, onError: (e) {
var reason = 'Expected future to complete successfully, but it failed '
'with ${e.error}';
- if (future.stackTrace != null) {
+ if (e.stackTrace != null) {
var stackTrace = e.stackTrace.toString();
stackTrace = ' ${stackTrace.replaceAll('\n', '\n ')}';
reason = '$reason\nStack trace:\n$stackTrace';
}
- expect(false, isTrue, reason: reason);
+ done(() => expect(false, isTrue, reason: reason));
});
return true;
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698