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 | 5 |
6 /** | 6 /** |
7 * Returns a matcher that matches empty strings, maps or collections. | 7 * Returns a matcher that matches empty strings, maps or collections. |
8 */ | 8 */ |
9 final Matcher isEmpty = const _Empty(); | 9 final Matcher isEmpty = const _Empty(); |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // expect() will show it for us. | 159 // expect() will show it for us. |
160 reason = new StringDescription(); | 160 reason = new StringDescription(); |
161 if (depth > 1) { | 161 if (depth > 1) { |
162 reason.add('expected ').addDescriptionOf(expected).add(' but was '). | 162 reason.add('expected ').addDescriptionOf(expected).add(' but was '). |
163 addDescriptionOf(actual); | 163 addDescriptionOf(actual); |
164 } else { | 164 } else { |
165 reason.add('was ').addDescriptionOf(actual); | 165 reason.add('was ').addDescriptionOf(actual); |
166 } | 166 } |
167 } | 167 } |
168 } | 168 } |
169 if (reason != null) { | 169 if (reason != null && location.length > 0) { |
170 reason.add(' ').add(location); | 170 reason.add(' ').add(location); |
171 } | 171 } |
172 return reason; | 172 return reason; |
173 } | 173 } |
174 | 174 |
175 String _match(expected, actual) { | 175 String _match(expected, actual) { |
176 Description reason = _recursiveMatch(expected, actual, '', 0); | 176 Description reason = _recursiveMatch(expected, actual, '', 0); |
177 return reason == null ? null : reason.toString(); | 177 return reason == null ? null : reason.toString(); |
178 } | 178 } |
179 | 179 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 final _matcher; | 587 final _matcher; |
588 final String _description; | 588 final String _description; |
589 | 589 |
590 const _Predicate(this._matcher, this._description); | 590 const _Predicate(this._matcher, this._description); |
591 | 591 |
592 bool matches(item) => _matcher(item); | 592 bool matches(item) => _matcher(item); |
593 | 593 |
594 Description describe(Description description) => | 594 Description describe(Description description) => |
595 description.add(_description); | 595 description.add(_description); |
596 } | 596 } |
OLD | NEW |