test/matcher
library
Classes
CustomMatcher
A base class for Matcher instances that match based on some feature of the
value under test.
Description
Matchers build up their error messages by appending to Description objects.
isInstanceOf <T >
DEPRECATED Use isA instead.
Matcher
The base class for all matchers.
StringDescription
The default implementation of Description . This should rarely need
substitution, although conceivably it is a place where other languages
could be supported.
TypeMatcher <T >
A Matcher subclass that supports validating the Type of the target
object.
Functions
addStateInfo (Map matchState , Map values )
→ void
Useful utility for nesting match states.
allOf (Object ? arg0 , [Object ? arg1 , Object ? arg2 , Object ? arg3 , Object ? arg4 , Object ? arg5 , Object ? arg6 ])
→ Matcher
This returns a matcher that matches if all of the matchers passed as
arguments (up to 7) match.
anyElement (Object ? valueOrMatcher )
→ Matcher
Returns a matcher which matches Iterable s in which at least one
element matches the given valueOrMatcher.
anyOf (Object ? arg0 , [Object ? arg1 , Object ? arg2 , Object ? arg3 , Object ? arg4 , Object ? arg5 , Object ? 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 (Object ? expected )
→ Matcher
Returns a matcher that matches if the match argument contains the expected
value.
containsAll (Iterable expected )
→ Matcher
Matches Iterable s which contain an element matching every value in
expected in any order, and may contain additional values.
containsAllInOrder (Iterable expected )
→ Matcher
Matches Iterable s which contain an element matching every value in
expected in the same order, but may contain additional values interleaved
throughout.
containsOnce (Object ? expected )
→ Matcher
Matches Iterable s where exactly one element matches the expected
value, and all other elements don't match.
containsPair (Object ? key , Object ? valueOrMatcher )
→ Matcher
Returns a matcher which matches maps containing the key-value pair
with key => valueOrMatcher.
containsValue (Object ? 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 (Object ? 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 (Object ? valueOrMatcher )
→ Matcher
Returns a matcher which matches Iterable s in which all elements
match the given valueOrMatcher.
greaterThan (Object value )
→ Matcher
Returns a matcher which matches if the match argument is greater
than the given value.
greaterThanOrEqualTo (Object value )
→ Matcher
Returns a matcher which matches if the match argument is greater
than or equal to the given value.
hasLength (Object ? matcher )
→ Matcher
Returns a matcher that matches if an object has a length property
that matches matcher.
hasNoRegexMatch (RegExp regex )
→ Matcher
hasRegexMatch (RegExp regex )
→ 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.
isA <T > ()
→ TypeMatcher <T >
Returns a matcher that matches objects with type T.
isIdentical (Object ? expected )
→ Matcher
isIn (Object ? expected )
→ Matcher
Returns a matcher that matches if the match argument is in
the expected value. This is the converse of contains .
isNot (Object ? valueOrMatcher )
→ Matcher
Returns a matcher that inverts valueOrMatcher to its logical negation.
isNotIdentical (Object ? expected )
→ Matcher
isSorted <T extends Comparable <T > > ()
→ Matcher
Matches Iterable s which are sorted.
isSortedBy <T , K extends Comparable <K > > (K keyOf (T ) )
→ Matcher
Matches Iterable s which are sorted by the keyOf property.
isSortedByCompare <T , K > (K keyOf (T ), Comparator <K > compare )
→ Matcher
Matches Iterable s which are compare-sorted by their keyOf property.
isSortedUsing <T > (Comparator <T > compare )
→ Matcher
Matches Iterable s which are compare-sorted.
lessThan (Object value )
→ Matcher
Returns a matcher which matches if the match argument is less
than the given value.
lessThanOrEqualTo (Object value )
→ Matcher
Returns a matcher which matches if the match argument is less
than or equal to the given value.
matches (Pattern 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 Iterable s that have the same
length and the same elements as expected, in the same order.
pairwiseCompare <S , T > (Iterable <S > expected , bool comparator (S , T ), String description )
→ Matcher
A pairwise matcher for Iterable s.
predicate <T > (bool f (T ), [String description = 'satisfies function' ])
→ Matcher
Returns a matcher that uses an arbitrary function that returns whether the
value is considered a match.
same (Object ? 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 Iterable s 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 Iterable s whose elements match the
matchers in expected, but not necessarily in the same order.
wrapMatcher (Object ? valueOrMatcher )
→ Matcher
Takes an argument and returns an equivalent Matcher .