matcher library

Classes

CustomMatcher
A useful utility class for implementing other matchers through inheritance. Derived classes should call the base constructor with a feature name and description, and an instance matcher, and should implement the featureValueOf abstract method. [...]
Description
Matchers build up their error messages by appending to Description objects. This interface is implemented by StringDescription. This interface is unlikely to need other implementations, but could be useful to replace in some cases - e.g. language conversion.
isInstanceOf<T>
Returns a matcher that matches if an object is an instance of T (or a subtype). [...]
Matcher
expect Matchers must implement/extend the Matcher class. [...]
StringDescription
The default implementation of Description. This should rarely need substitution, although conceivably it is a place where other languages could be supported.
TypeMatcher

Constants

anything → const Matcher
A matcher that matches any value.
const _IsAnything()
isArgumentError → const Matcher
A matcher for ArgumentErrors.
const _ArgumentError()
isConcurrentModificationError → const Matcher
A matcher for ConcurrentModificationError.
const _ConcurrentModificationError()
isCyclicInitializationError → const Matcher
A matcher for CyclicInitializationError.
const _CyclicInitializationError()
isEmpty → const Matcher
Returns a matcher that matches the isEmpty property.
const _Empty()
isException → const Matcher
A matcher for Exceptions.
const _Exception()
isFalse → const Matcher
A matcher that matches anything except the Boolean value true.
const _IsFalse()
isFormatException → const Matcher
A matcher for FormatExceptions.
const _FormatException()
isList → const Matcher
A matcher for List types.
const _IsList()
isMap → const Matcher
A matcher for Map types.
const _IsMap()
isNaN → const Matcher
A matcher that matches the numeric value NaN.
const _IsNaN()
isNegative → const Matcher
A matcher which matches if the match argument is negative.
const _OrderingMatcher(0, false, true, false, 'a negative value', false)
isNonNegative → const Matcher
A matcher which matches if the match argument is zero or positive.
const _OrderingMatcher(0, true, false, true, 'a non-negative value', false)
isNonPositive → const Matcher
A matcher which matches if the match argument is zero or negative.
const _OrderingMatcher(0, true, true, false, 'a non-positive value', false)
isNonZero → const Matcher
A matcher which matches if the match argument is non-zero.
const _OrderingMatcher(0, false, true, true, 'a value not equal to')
isNoSuchMethodError → const Matcher
A matcher for NoSuchMethodErrors.
const _NoSuchMethodError()
isNotEmpty → const Matcher
Returns a matcher that matches the isNotEmpty property.
const _NotEmpty()
isNotNaN → const Matcher
A matcher that matches any non-NaN value.
const _IsNotNaN()
isNotNull → const Matcher
A matcher that matches any non-null value.
const _IsNotNull()
isNull → const Matcher
A matcher that matches any null value.
const _IsNull()
isNullThrownError → const Matcher
A matcher for NullThrownError.
const _NullThrownError()
isPositive → const Matcher
A matcher which matches if the match argument is positive.
const _OrderingMatcher(0, false, false, true, 'a positive value', false)
isRangeError → const Matcher
A matcher for RangeErrors.
const _RangeError()
isStateError → const Matcher
A matcher for StateErrors.
const _StateError()
isTrue → const Matcher
A matcher that matches the Boolean value true.
const _IsTrue()
isUnimplementedError → const Matcher
A matcher for UnimplementedErrors.
const _UnimplementedError()
isUnsupportedError → const Matcher
A matcher for UnsupportedError.
const _UnsupportedError()
isZero → const Matcher
A matcher which matches if the match argument is zero.
const _OrderingMatcher(0, true, false, false, 'a value equal to')
returnsNormally → const Matcher
A matcher that matches a function call against no exception. [...]
const _ReturnsNormally()

Functions

addStateInfo(Map matchState, Map values) → void
Useful utility for nesting match states.
allOf(dynamic arg0, [ dynamic arg1, dynamic arg2, dynamic arg3, dynamic arg4, dynamic arg5, dynamic arg6 ]) Matcher
This returns a matcher that matches if all of the matchers passed as arguments (up to 7) match. [...]
anyElement(dynamic matcher) Matcher
Returns a matcher which matches Iterables in which at least one element matches the given matcher.
anyOf(dynamic arg0, [ dynamic arg1, dynamic arg2, dynamic arg3, dynamic arg4, dynamic arg5, dynamic arg6 ]) Matcher
Matches if any of the given matchers evaluate to true. [...]
closeTo(num value, num delta) Matcher
Returns a matcher which matches if the match argument is within delta of some value. [...]
collapseWhitespace(String string) String
Utility function to collapse whitespace runs to single spaces and strip leading/trailing whitespace.
contains(dynamic expected) Matcher
Returns a matcher that matches if the match argument contains the expected value. [...]
containsAllInOrder(Iterable expected) Matcher
Matches Iterables which contain an element matching every value in expected in the same order, but may contain additional values interleaved throughout. [...]
containsPair(dynamic key, dynamic value) Matcher
Returns a matcher which matches maps containing the key-value pair with key => value.
containsValue(dynamic value) Matcher
Returns a matcher which matches maps containing the given value.
endsWith(String suffixString) Matcher
Returns a matcher that matches if the match argument is a string and ends with suffixString.
equals(dynamic expected, [ int limit = 100 ]) Matcher
Returns a matcher that matches if the value is structurally equal to expected. [...]
equalsIgnoringCase(String value) Matcher
Returns a matcher which matches if the match argument is a string and is equal to value when compared case-insensitively.
equalsIgnoringWhitespace(String value) Matcher
Returns a matcher which matches if the match argument is a string and is equal to value, ignoring whitespace. [...]
escape(String str) String
Returns str with all whitespace characters represented as their escape sequences. [...]
everyElement(dynamic matcher) Matcher
Returns a matcher which matches Iterables in which all elements match the given matcher.
greaterThan(dynamic value) Matcher
Returns a matcher which matches if the match argument is greater than the given value.
greaterThanOrEqualTo(dynamic value) Matcher
Returns a matcher which matches if the match argument is greater than or equal to the given value.
hasLength(dynamic matcher) Matcher
Returns a matcher that matches if an object has a length property that matches matcher.
inClosedOpenRange(num low, num high) Matcher
Returns a matcher which matches if the match argument is greater than or equal to a low and less than high.
inExclusiveRange(num low, num high) Matcher
Returns a matcher which matches if the match argument is greater than low and less than high.
inInclusiveRange(num low, num high) Matcher
Returns a matcher which matches if the match argument is greater than or equal to low and less than or equal to high.
inOpenClosedRange(num low, num high) Matcher
Returns a matcher which matches if the match argument is greater than low and less than or equal to high.
isIn(dynamic expected) Matcher
Returns a matcher that matches if the match argument is in the expected value. This is the converse of contains.
isNot(dynamic matcher) Matcher
This returns a matcher that inverts matcher to its logical negation.
lessThan(dynamic value) Matcher
Returns a matcher which matches if the match argument is less than the given value.
lessThanOrEqualTo(dynamic value) Matcher
Returns a matcher which matches if the match argument is less than or equal to the given value.
matches(dynamic re) Matcher
Returns a matcher that matches if the match argument is a string and matches the regular expression given by re. [...]
orderedEquals(Iterable expected) Matcher
Returns a matcher which matches Iterables that have the same length and the same elements as expected, in the same order. [...]
pairwiseCompare<S, T>(Iterable<S> expected, bool comparator(S a, T b), String description) Matcher
A pairwise matcher for Iterables. [...]
predicate<T>(bool f(T value), [ String description = 'satisfies function' ]) Matcher
Returns a matcher that uses an arbitrary function that returns true or false for the actual value. [...]
same(dynamic expected) Matcher
Returns a matches that matches if the value is the same instance as expected, using identical.
startsWith(String prefixString) Matcher
Returns a matcher that matches if the match argument is a string and starts with prefixString.
stringContainsInOrder(List<String> substrings) Matcher
Returns a matcher that matches if the match argument is a string and contains a given list of substrings in relative order. [...]
unorderedEquals(Iterable expected) Matcher
Returns a matcher which matches Iterables that have the same length and the same elements as expected, but not necessarily in the same order. [...]
unorderedMatches(Iterable expected) Matcher
Returns a matcher which matches Iterables whose elements match the matchers in expected, but not necessarily in the same order. [...]
wrapMatcher(dynamic x) Matcher
Takes an argument and returns an equivalent Matcher. [...]