_Mismatch? _compareSets()

in lib/src/equals_matcher.dart [137:164]


  _Mismatch? _compareSets(Set expected, Object? actual,
      _RecursiveMatcher matcher, int depth, String location) {
    if (actual is Iterable) {
      var other = actual.toSet();

      for (var expectedElement in expected) {
        if (other.every((actualElement) =>
            matcher(expectedElement, actualElement, location, depth) != null)) {
          return _Mismatch(
              location,
              actual,
              (description, verbose) => description
                  .add('does not contain ')
                  .addDescriptionOf(expectedElement));
        }
      }

      if (other.length > expected.length) {
        return _Mismatch.simple(location, actual, 'larger than expected');
      } else if (other.length < expected.length) {
        return _Mismatch.simple(location, actual, 'smaller than expected');
      } else {
        return null;
      }
    } else {
      return _Mismatch.simple(location, actual, 'is not Iterable');
    }
  }