| OLD | NEW |
| 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 library matcher.future_matchers; | 5 library matcher.future_matchers; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'expect.dart'; | 9 import 'expect.dart'; |
| 10 import 'interfaces.dart'; | 10 import 'interfaces.dart'; |
| 11 import 'util.dart'; | 11 import 'util.dart'; |
| 12 | 12 |
| 13 /// Matches a [Future] that completes successfully with a value. Note that this | 13 /// Matches a [Future] that completes successfully with a value. |
| 14 /// creates an asynchronous expectation. The call to `expect()` that includes | 14 /// |
| 15 /// this will return immediately and execution will continue. Later, when the | 15 /// Note that this creates an asynchronous expectation. The call to `expect()` |
| 16 /// future completes, the actual expectation will run. | 16 /// that includes this will return immediately and execution will continue. |
| 17 /// Later, when the future completes, the actual expectation will run. |
| 17 /// | 18 /// |
| 18 /// To test that a Future completes with an exception, you can use [throws] and | 19 /// To test that a Future completes with an exception, you can use [throws] and |
| 19 /// [throwsA]. | 20 /// [throwsA]. |
| 20 final Matcher completes = const _Completes(null, ''); | 21 final Matcher completes = const _Completes(null, ''); |
| 21 | 22 |
| 22 /// Matches a [Future] that completes succesfully with a value that matches | 23 /// Matches a [Future] that completes succesfully with a value that matches |
| 23 /// [matcher]. Note that this creates an asynchronous expectation. The call to | 24 /// [matcher]. |
| 25 /// |
| 26 /// Note that this creates an asynchronous expectation. The call to |
| 24 /// `expect()` that includes this will return immediately and execution will | 27 /// `expect()` that includes this will return immediately and execution will |
| 25 /// continue. Later, when the future completes, the actual expectation will run. | 28 /// continue. Later, when the future completes, the actual expectation will run. |
| 26 /// | 29 /// |
| 27 /// To test that a Future completes with an exception, you can use [throws] and | 30 /// To test that a Future completes with an exception, you can use [throws] and |
| 28 /// [throwsA]. | 31 /// [throwsA]. |
| 29 /// | 32 /// |
| 30 /// [id] is an optional tag that can be used to identify the completion matcher | 33 /// [id] is an optional tag that can be used to identify the completion matcher |
| 31 /// in error messages. | 34 /// in error messages. |
| 32 Matcher completion(matcher, [String id = '']) => | 35 Matcher completion(matcher, [String id = '']) => |
| 33 new _Completes(wrapMatcher(matcher), id); | 36 new _Completes(wrapMatcher(matcher), id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 61 | 64 |
| 62 Description describe(Description description) { | 65 Description describe(Description description) { |
| 63 if (_matcher == null) { | 66 if (_matcher == null) { |
| 64 description.add('completes successfully'); | 67 description.add('completes successfully'); |
| 65 } else { | 68 } else { |
| 66 description.add('completes to a value that ').addDescriptionOf(_matcher); | 69 description.add('completes to a value that ').addDescriptionOf(_matcher); |
| 67 } | 70 } |
| 68 return description; | 71 return description; |
| 69 } | 72 } |
| 70 } | 73 } |
| OLD | NEW |