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 28 matching lines...) Expand all Loading... |
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 BaseMatcher { |
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, MatchState 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 |
54 var description = _description; | 54 var description = _description; |
55 if (description == null) { | 55 if (description == null) { |
56 if (_matcher == null) { | 56 if (_matcher == null) { |
57 description = 'expect(..., completes)'; | 57 description = 'expect(..., completes)'; |
58 } else { | 58 } else { |
59 var matcherDescription = new StringDescription(); | 59 var matcherDescription = new StringDescription(); |
(...skipping 17 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 |