OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * BaseMatcher is the base class for all matchers. To implement a new |
| 7 * matcher, either add a class that implements from IMatcher or |
| 8 * a class that inherits from Matcher. Inheriting from Matcher has |
| 9 * the benefit that a default implementation of describeMismatch will |
| 10 * be provided. |
| 11 */ |
| 12 |
| 13 class BaseMatcher implements Matcher { |
| 14 const BaseMatcher(); |
| 15 |
| 16 /** |
| 17 * Tests the matcher against a given [item] |
| 18 * and return true if the match succeeds; false otherwise. |
| 19 */ |
| 20 abstract bool matches(item); |
| 21 |
| 22 /** |
| 23 * Creates a textual description of a matcher, |
| 24 * by appending to [mismatchDescription]. |
| 25 */ |
| 26 abstract Description describe(Description mismatchDescription); |
| 27 |
| 28 /** |
| 29 * Generates a description of the matcher failed for a particular |
| 30 * [item], by appending the description to [mismatchDescription]. |
| 31 * It does not check whether the [item] fails the match, as it is |
| 32 * only called after a failed match. |
| 33 */ |
| 34 Description describeMismatch(item, Description mismatchDescription) => |
| 35 mismatchDescription.add('was ').addDescriptionOf(item); |
| 36 } |
OLD | NEW |