matches method

bool matches (dynamic item, Map matchState)
inherited

Does the matching of the actual vs expected values.

item is the actual value. matchState can be supplied and may be used to add details about the mismatch that are too costly to determine in describeMismatch.

Implementation

bool matches(item, Map matchState) {
  var result = matchAsync(item);
  expect(result,
      anyOf([equals(null), TypeMatcher<Future>(), TypeMatcher<String>()]),
      reason: "matchAsync() may only return a String, a Future, or null.");

  if (result is Future) {
    Invoker.current.addOutstandingCallback();
    result.then((realResult) {
      if (realResult != null) {
        // ignore: deprecated_member_use
        fail(formatFailure(this, item, realResult as String));
      }
      Invoker.current.removeOutstandingCallback();
    });
  } else if (result is String) {
    matchState[this] = result;
    return false;
  }

  return true;
}