| 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 * MatchState is a simple wrapper around an arbitrary object. | 6 * MatchState is a simple wrapper around an arbitrary object. |
| 7 * [Matcher] [matches] methods can use this to store useful | 7 * [Matcher] [matches] methods can use this to store useful |
| 8 * information upon match failures, and this information will | 8 * information upon match failures, and this information will |
| 9 * be passed to [describeMismatch]. Each [Matcher] is responsible | 9 * be passed to [describeMismatch]. Each [Matcher] is responsible |
| 10 * for its own use of this state, so the state created by [matches] | 10 * for its own use of this state, so the state created by [matches] |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 */ | 31 */ |
| 32 abstract class BaseMatcher implements Matcher { | 32 abstract class BaseMatcher implements Matcher { |
| 33 const BaseMatcher(); | 33 const BaseMatcher(); |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Tests the matcher against a given [item] | 36 * Tests the matcher against a given [item] |
| 37 * and return true if the match succeeds; false otherwise. | 37 * and return true if the match succeeds; false otherwise. |
| 38 * [matchState] may be used to return additional info for | 38 * [matchState] may be used to return additional info for |
| 39 * the use of [describeMismatch]. | 39 * the use of [describeMismatch]. |
| 40 */ | 40 */ |
| 41 abstract bool matches(item, MatchState matchState); | 41 bool matches(item, MatchState matchState); |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Creates a textual description of a matcher, | 44 * Creates a textual description of a matcher, |
| 45 * by appending to [mismatchDescription]. | 45 * by appending to [mismatchDescription]. |
| 46 */ | 46 */ |
| 47 abstract Description describe(Description mismatchDescription); | 47 Description describe(Description mismatchDescription); |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * Generates a description of the matcher failed for a particular | 50 * Generates a description of the matcher failed for a particular |
| 51 * [item], by appending the description to [mismatchDescription]. | 51 * [item], by appending the description to [mismatchDescription]. |
| 52 * It does not check whether the [item] fails the match, as it is | 52 * It does not check whether the [item] fails the match, as it is |
| 53 * only called after a failed match. There may be additional info | 53 * only called after a failed match. There may be additional info |
| 54 * about the mismatch in [matchState]. | 54 * about the mismatch in [matchState]. |
| 55 */ | 55 */ |
| 56 Description describeMismatch(item, Description mismatchDescription, | 56 Description describeMismatch(item, Description mismatchDescription, |
| 57 MatchState matchState, bool verbose) => | 57 MatchState matchState, bool verbose) => |
| 58 mismatchDescription.add('was ').addDescriptionOf(item); | 58 mismatchDescription.add('was ').addDescriptionOf(item); |
| 59 } | 59 } |
| OLD | NEW |