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

Side by Side Diff: pkg/matcher/lib/src/future_matchers.dart

Issue 306283002: pkg/matcher: cleanup, updates, deprecations, fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of matcher; 5 library matcher.future_matchers;
6 6
7 /** 7 import 'dart:async';
8 * Matches a [Future] that completes successfully with a value. Note that this 8
9 * creates an asynchronous expectation. The call to `expect()` that includes 9 import 'core_matchers.dart';
10 * this will return immediately and execution will continue. Later, when the 10 import 'expect.dart';
11 * future completes, the actual expectation will run. 11 import 'interfaces.dart';
12 * 12
13 * To test that a Future completes with an exception, you can use [throws] and 13 /// Matches a [Future] that completes successfully with a value. Note that this
14 * [throwsA]. 14 /// creates an asynchronous expectation. The call to `expect()` that includes
15 */ 15 /// this will return immediately and execution will continue. Later, when the
16 /// future completes, the actual expectation will run.
17 ///
18 /// To test that a Future completes with an exception, you can use [throws] and
19 /// [throwsA].
16 final Matcher completes = const _Completes(null, ''); 20 final Matcher completes = const _Completes(null, '');
17 21
18 /** 22 /// Matches a [Future] that completes succesfully with a value that matches
19 * Matches a [Future] that completes succesfully with a value that matches 23 /// [matcher]. Note that this creates an asynchronous expectation. The call to
20 * [matcher]. Note that this creates an asynchronous expectation. The call to 24 /// `expect()` that includes this will return immediately and execution will
21 * `expect()` that includes this will return immediately and execution will 25 /// continue. Later, when the future completes, the actual expectation will run.
22 * continue. Later, when the future completes, the actual expectation will run. 26 ///
23 * 27 /// To test that a Future completes with an exception, you can use [throws] and
24 * To test that a Future completes with an exception, you can use [throws] and 28 /// [throwsA].
25 * [throwsA]. 29 ///
26 * 30 /// [id] is an optional tag that can be used to identify the completion matcher
27 * [id] is an optional tag that can be used to identify the completion matcher 31 /// in error messages.
28 * in error messages.
29 */
30 Matcher completion(matcher, [String id = '']) => 32 Matcher completion(matcher, [String id = '']) =>
31 new _Completes(wrapMatcher(matcher), id); 33 new _Completes(wrapMatcher(matcher), id);
32 34
33 class _Completes extends Matcher { 35 class _Completes extends Matcher {
34 final Matcher _matcher; 36 final Matcher _matcher;
35 final String _id; 37 final String _id;
36 38
37 const _Completes(this._matcher, this._id); 39 const _Completes(this._matcher, this._id);
38 40
39 bool matches(item, Map matchState) { 41 bool matches(item, Map matchState) {
(...skipping 19 matching lines...) Expand all
59 61
60 Description describe(Description description) { 62 Description describe(Description description) {
61 if (_matcher == null) { 63 if (_matcher == null) {
62 description.add('completes successfully'); 64 description.add('completes successfully');
63 } else { 65 } else {
64 description.add('completes to a value that ').addDescriptionOf(_matcher); 66 description.add('completes to a value that ').addDescriptionOf(_matcher);
65 } 67 }
66 return description; 68 return description;
67 } 69 }
68 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698