This builds a textual description of a specific mismatch. item
is the value that was tested by matches
; matchState
is
the Map
that was passed to and supplemented by matches
with additional information about the mismatch, and mismatchDescription
is the Description
that is being built to decribe the mismatch.
A few matchers make use of the verbose
flag to provide detailed
information that is not typically included but can be of help in
diagnosing failures, such as stack traces.
Source
Description describeMismatch( item, Description mismatchDescription, Map matchState, bool verbose) { if (item is! Function && item is! Future) { return mismatchDescription.add('is not a Function or Future'); } else if (_matcher == null || matchState['exception'] == null) { return mismatchDescription.add('did not throw'); } else { mismatchDescription .add('threw ') .addDescriptionOf(matchState['exception']); if (verbose) { mismatchDescription.add(' at ').add(matchState['stack'].toString()); } return mismatchDescription; } }