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

Unified Diff: lib/src/future_matchers.dart

Issue 934413002: Replace the existing unittest APIs with the new runner infrastructure. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Code review changes Created 5 years, 10 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 | « lib/src/expected_function.dart ('k') | lib/src/group_context.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/future_matchers.dart
diff --git a/lib/src/future_matchers.dart b/lib/src/future_matchers.dart
index 5d873383a596ca235ceb13f5011447fe2c719806..2ae13eebd367df34276a7e6ea6b5a10718d21c84 100644
--- a/lib/src/future_matchers.dart
+++ b/lib/src/future_matchers.dart
@@ -8,7 +8,9 @@ import 'dart:async';
import 'package:matcher/matcher.dart' hide throws, throwsA, expect, fail;
-import '../unittest.dart';
+import 'expect.dart';
+import 'invoker.dart';
+import 'utils.dart';
/// Matches a [Future] that completes successfully with a value.
///
@@ -43,22 +45,26 @@ class _Completes extends Matcher {
bool matches(item, Map matchState) {
if (item is! Future) return false;
- var done = expectAsync((fn) => fn(), id: _id);
+ Invoker.current.addOutstandingCallback();
item.then((value) {
- done(() {
- if (_matcher != null) expect(value, _matcher);
- });
+ if (_matcher != null) expect(value, _matcher);
+ Invoker.current.removeOutstandingCallback();
}, onError: (error, trace) {
+ if (error is TestFailure) {
+ Invoker.current.handleError(error, trace);
+ return;
+ }
+
var id = _id == '' ? '' : '${_id} ';
var reason = 'Expected future ${id}to complete successfully, '
'but it failed with ${error}';
if (trace != null) {
- var stackTrace = trace.toString();
+ var stackTrace = terseChain(trace).toString();
stackTrace = ' ${stackTrace.replaceAll('\n', '\n ')}';
reason = '$reason\nStack trace:\n$stackTrace';
}
- done(() => fail(reason));
+ fail(reason);
});
return true;
« no previous file with comments | « lib/src/expected_function.dart ('k') | lib/src/group_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698