| 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 part of matcher; | 5 part of matcher; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Returns a matcher which matches if the match argument is a string and | 8 * Returns a matcher which matches if the match argument is a string and |
| 9 * is equal to [value] when compared case-insensitively. | 9 * is equal to [value] when compared case-insensitively. |
| 10 */ | 10 */ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 bool matches(item, MatchState matchState) => | 47 bool matches(item, MatchState matchState) => |
| 48 item is String && _matchValue == collapseWhitespace(item); | 48 item is String && _matchValue == collapseWhitespace(item); |
| 49 | 49 |
| 50 Description describe(Description description) => | 50 Description describe(Description description) => |
| 51 description.addDescriptionOf(_matchValue).add(' ignoring whitespace'); | 51 description.addDescriptionOf(_matchValue).add(' ignoring whitespace'); |
| 52 | 52 |
| 53 Description describeMismatch(item, Description mismatchDescription, | 53 Description describeMismatch(item, Description mismatchDescription, |
| 54 MatchState matchState, bool verbose) { | 54 MatchState matchState, bool verbose) { |
| 55 if (item is String) { | 55 if (item is String) { |
| 56 return mismatchDescription.add('was '). | 56 return mismatchDescription.add('is '). |
| 57 addDescriptionOf(collapseWhitespace(item)); | 57 addDescriptionOf(collapseWhitespace(item)). |
| 58 add(' with whitespace compressed'); |
| 58 } else { | 59 } else { |
| 59 return super.describeMismatch(item, mismatchDescription, | 60 return super.describeMismatch(item, mismatchDescription, |
| 60 matchState, verbose); | 61 matchState, verbose); |
| 61 } | 62 } |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 /** | 66 /** |
| 66 * Utility function to collapse whitespace runs to single spaces | 67 * Utility function to collapse whitespace runs to single spaces |
| 67 * and strip leading/trailing whitespace. | 68 * and strip leading/trailing whitespace. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 if (!(item is String)) { | 195 if (!(item is String)) { |
| 195 return mismatchDescription. | 196 return mismatchDescription. |
| 196 addDescriptionOf(item). | 197 addDescriptionOf(item). |
| 197 add(' not a string'); | 198 add(' not a string'); |
| 198 } else { | 199 } else { |
| 199 return super.describeMismatch(item, mismatchDescription, | 200 return super.describeMismatch(item, mismatchDescription, |
| 200 matchState, verbose); | 201 matchState, verbose); |
| 201 } | 202 } |
| 202 } | 203 } |
| 203 } | 204 } |
| OLD | NEW |