| 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 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 |
| 35 /// matcher in error messages. | 35 /// matcher in error messages. |
| 36 /// | 36 /// |
| 37 /// This differs from the `completion` matcher in `unittest` in that it pipes | 37 /// This differs from the `completion` matcher in `unittest` in that it pipes |
| 38 /// any errors in the Future to [currentSchedule], rather than reporting them in | 38 /// any errors in the Future to [currentSchedule], rather than reporting them in |
| 39 /// the [expect]'s error message. | 39 /// the [expect]'s error message. |
| 40 Matcher completion(matcher, [String description]) => | 40 Matcher completion(matcher, [String description]) => |
| 41 new _ScheduledCompletes(wrapMatcher(matcher), description); | 41 new _ScheduledCompletes(wrapMatcher(matcher), description); |
| 42 | 42 |
| 43 class _ScheduledCompletes extends BaseMatcher { | 43 class _ScheduledCompletes extends Matcher { |
| 44 final Matcher _matcher; | 44 final Matcher _matcher; |
| 45 final String _description; | 45 final String _description; |
| 46 | 46 |
| 47 const _ScheduledCompletes(this._matcher, this._description); | 47 const _ScheduledCompletes(this._matcher, this._description); |
| 48 | 48 |
| 49 bool matches(item, Map matchState) { | 49 bool matches(item, Map matchState) { |
| 50 if (item is! Future) return false; | 50 if (item is! Future) return false; |
| 51 | 51 |
| 52 // TODO(nweiz): parse the stack, figure out on what line these were called, | 52 // TODO(nweiz): parse the stack, figure out on what line these were called, |
| 53 // and include that in their descriptions | 53 // and include that in their descriptions |
| (...skipping 23 matching lines...) Expand all 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 |