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

Unified Diff: lib/src/future_matchers.dart

Issue 955543002: Move a bunch of src/ files into subdirectories. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Fix library tags 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/frontend/throws_matchers.dart ('k') | lib/src/group.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
deleted file mode 100644
index 2ae13eebd367df34276a7e6ea6b5a10718d21c84..0000000000000000000000000000000000000000
--- a/lib/src/future_matchers.dart
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library unittest.future_matchers;
-
-import 'dart:async';
-
-import 'package:matcher/matcher.dart' hide throws, throwsA, expect, fail;
-
-import 'expect.dart';
-import 'invoker.dart';
-import 'utils.dart';
-
-/// Matches a [Future] that completes successfully with a value.
-///
-/// Note that this creates an asynchronous expectation. The call to `expect()`
-/// that includes this will return immediately and execution will continue.
-/// Later, when the future completes, the actual expectation will run.
-///
-/// To test that a Future completes with an exception, you can use [throws] and
-/// [throwsA].
-final Matcher completes = const _Completes(null, '');
-
-/// Matches a [Future] that completes succesfully with a value that matches
-/// [matcher].
-///
-/// Note that this creates an asynchronous expectation. The call to
-/// `expect()` that includes this will return immediately and execution will
-/// continue. Later, when the future completes, the actual expectation will run.
-///
-/// 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);
-
-class _Completes extends Matcher {
- final Matcher _matcher;
- final String _id;
-
- const _Completes(this._matcher, this._id);
-
- bool matches(item, Map matchState) {
- if (item is! Future) return false;
- Invoker.current.addOutstandingCallback();
-
- item.then((value) {
- 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 = terseChain(trace).toString();
- stackTrace = ' ${stackTrace.replaceAll('\n', '\n ')}';
- reason = '$reason\nStack trace:\n$stackTrace';
- }
- fail(reason);
- });
-
- return true;
- }
-
- Description describe(Description description) {
- if (_matcher == null) {
- description.add('completes successfully');
- } else {
- description.add('completes to a value that ').addDescriptionOf(_matcher);
- }
- return description;
- }
-}
« no previous file with comments | « lib/src/frontend/throws_matchers.dart ('k') | lib/src/group.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698