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

Unified Diff: lib/src/frontend/future_matchers.dart

Issue 1158463003: Don't wrap exceptions in complete or completes(). (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 7 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 | « CHANGELOG.md ('k') | test/frontend/matcher/completion_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/frontend/future_matchers.dart
diff --git a/lib/src/frontend/future_matchers.dart b/lib/src/frontend/future_matchers.dart
index a5b86daa80bd1afcd2712adac85ad57fff042329..3a4b6248ab08f8ab61a6b3862026e4a5cfe555d2 100644
--- a/lib/src/frontend/future_matchers.dart
+++ b/lib/src/frontend/future_matchers.dart
@@ -20,7 +20,7 @@ import 'expect.dart';
///
/// To test that a Future completes with an exception, you can use [throws] and
/// [throwsA].
-final Matcher completes = const _Completes(null, '');
+final Matcher completes = const _Completes(null);
/// Matches a [Future] that completes succesfully with a value that matches
/// [matcher].
@@ -32,16 +32,14 @@ final Matcher completes = const _Completes(null, '');
/// To test that a Future completes with an exception, you can use [throws] and
/// [throwsA].
///
-/// [description] is an optional tag that can be used to identify the completion
-/// matcher in error messages.
-Matcher completion(matcher, [String description = '']) =>
- new _Completes(wrapMatcher(matcher), description);
+/// The [description] parameter is deprecated and shouldn't be used.
+Matcher completion(matcher, [@deprecated String description]) =>
+ new _Completes(wrapMatcher(matcher));
class _Completes extends Matcher {
final Matcher _matcher;
- final String _id;
- const _Completes(this._matcher, this._id);
+ const _Completes(this._matcher);
bool matches(item, Map matchState) {
if (item is! Future) return false;
@@ -50,19 +48,6 @@ class _Completes extends Matcher {
item.then((value) {
if (_matcher != null) expect(value, _matcher);
Invoker.current.removeOutstandingCallback();
- }, onError: (error, trace) {
- if (error is TestFailure) throw error;
-
- var id = _id == '' ? '' : '${_id} ';
- var reason = 'Expected future ${id}to complete successfully, '
- 'but it failed with ${error}';
- if (trace != null) {
- var stackTrace = terseChain(trace,
- verbose: Invoker.current.metadata.verboseTrace);
- stackTrace = ' ${stackTrace.toString().replaceAll('\n', '\n ')}';
- reason = '$reason\nStack trace:\n$stackTrace';
- }
- fail(reason);
});
return true;
« no previous file with comments | « CHANGELOG.md ('k') | test/frontend/matcher/completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698