| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 scheduled_future_matchers; | 5 library scheduled_future_matchers; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 | 10 |
| 11 import '../scheduled_test.dart'; | 11 import '../scheduled_test.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. Note that this |
| 14 /// creates an asynchronous expectation. The call to `expect()` that includes | 14 /// creates an asynchronous expectation. The call to `expect()` that includes |
| 15 /// this will return immediately and execution will continue. Later, when the | 15 /// this will return immediately and execution will continue. Later, when the |
| 16 /// future completes, the actual expectation will run. | 16 /// future completes, the actual expectation will run. |
| 17 /// | 17 /// |
| 18 /// To test that a Future completes with an exception, you can use [throws] and | 18 /// To test that a Future completes with an exception, you can use [throws] and |
| 19 /// [throwsA]. | 19 /// [throwsA]. |
| 20 /// | 20 /// |
| 21 /// This differs from the `completes` matcher in `unittest` in that it pipes any | 21 /// This differs from the `completes` matcher in `unittest` in that it pipes any |
| 22 /// errors in the Future to [currentSchedule], rather than reporting them in the | 22 /// errors in the Future to [currentSchedule], rather than reporting them in the |
| 23 /// [expect]'s error message. | 23 /// [expect]'s error message. |
| 24 Matcher completes = const _ScheduledCompletes(null, null); | 24 final Matcher completes = const _ScheduledCompletes(null, null); |
| 25 | 25 |
| 26 /// Matches a [Future] that completes succesfully with a value that matches | 26 /// Matches a [Future] that completes succesfully with a value that matches |
| 27 /// [matcher]. Note that this creates an asynchronous expectation. The call to | 27 /// [matcher]. Note that this creates an asynchronous expectation. The call to |
| 28 /// `expect()` that includes this will return immediately and execution will | 28 /// `expect()` that includes this will return immediately and execution will |
| 29 /// continue. Later, when the future completes, the actual expectation will run. | 29 /// continue. Later, when the future completes, the actual expectation will run. |
| 30 /// | 30 /// |
| 31 /// To test that a Future completes with an exception, you can use [throws] and | 31 /// To test that a Future completes with an exception, you can use [throws] and |
| 32 /// [throwsA]. | 32 /// [throwsA]. |
| 33 /// | 33 /// |
| 34 /// [description] is an optional tag that can be used to identify the completion | 34 /// [description] is an optional tag that can be used to identify the completion |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 Description describe(Description description) { | 78 Description describe(Description description) { |
| 79 if (_matcher == null) { | 79 if (_matcher == null) { |
| 80 description.add('completes successfully'); | 80 description.add('completes successfully'); |
| 81 } else { | 81 } else { |
| 82 description.add('completes to a value that ').addDescriptionOf(_matcher); | 82 description.add('completes to a value that ').addDescriptionOf(_matcher); |
| 83 } | 83 } |
| 84 return description; | 84 return description; |
| 85 } | 85 } |
| 86 } | 86 } |
| OLD | NEW |