Dart DocumentationmatcherBaseMatcher

BaseMatcher abstract class

BaseMatcher is the base class for all matchers. To implement a new matcher, either add a class that implements Matcher or a class that extends BaseMatcher. Extending BaseMatcher has the benefit that a default implementation of describeMismatch will be provided.

abstract class BaseMatcher implements Matcher {
 const BaseMatcher();

 /**
  * Tests the matcher against a given [item]
  * and return true if the match succeeds; false otherwise.
  * [matchState] may be used to return additional info for
  * the use of [describeMismatch].
  */
 bool matches(item, MatchState matchState);

 /**
  * Creates a textual description of a matcher,
  * by appending to [mismatchDescription].
  */
 Description describe(Description mismatchDescription);

 /**
  * Generates a description of the matcher failed for a particular
  * [item], by appending the description to [mismatchDescription].
  * It does not check whether the [item] fails the match, as it is
  * only called after a failed match. There may be additional info
  * about the mismatch in [matchState].
  */
 Description describeMismatch(item, Description mismatchDescription,
                              MatchState matchState, bool verbose) =>
   mismatchDescription.add('was ').addDescriptionOf(item);
}

Subclasses

CustomMatcher, Throws, TypeMatcher, isInstanceOf<T>

Implements

Matcher

Constructors

const BaseMatcher() #

const BaseMatcher();

Methods

abstract Description describe(Description mismatchDescription) #

Creates a textual description of a matcher, by appending to mismatchDescription.

Description describeMismatch(item, Description mismatchDescription, MatchState matchState, bool verbose) #

Generates a description of the matcher failed for a particular item, by appending the description to mismatchDescription. It does not check whether the item fails the match, as it is only called after a failed match. There may be additional info about the mismatch in matchState.

Description describeMismatch(item, Description mismatchDescription,
                            MatchState matchState, bool verbose) =>
 mismatchDescription.add('was ').addDescriptionOf(item);

abstract bool matches(item, MatchState matchState) #

Tests the matcher against a given item and return true if the match succeeds; false otherwise. matchState may be used to return additional info for the use of describeMismatch.