deepEquals method

void deepEquals(
  1. Iterable<Object?> expected
)

Expects that the iterable contains elements that are deeply equal to the elements of expected.

Elements, keys, or values within expected which are a collections are deeply compared for equality with a collection in the same position within actual. Elements which are collection types are note compared with the native identity based equality or custom equality operator overrides.

Elements, keys, or values within expected which are Condition callbacks are run against the value in the same position within actual. Condition callbacks must take a Subject<Object?> or Subject<dynamic> and may not use a more specific generic. Use (Subject<Object?> s) => s.isA<Type>() to check expectations for specific element types. Note also that the argument type Subject<Object?> cannot be inferred and must be explicit in the function definition.

Elements, keys, or values within expected which are any other type are compared using operator == equality.

Comparing sets or maps will have a runtime which is polynomial on the the size of those collections. Does not use Set.contains or Map.containsKey, there will not be runtime benefits from hashing. Custom collection behavior is ignored. For example, it is not possible to distinguish between a Set and a Set.identity.

Collections may be nested to a maximum depth of 1000. Recursive collections are not allowed.

Implementation

void deepEquals(Iterable<Object?> expected) => context
        .expect(() => prefixFirst('is deeply equal to ', literal(expected)),
            (actual) {
      final which = deepCollectionEquals(actual, expected);
      if (which == null) return null;
      return Rejection(which: which);
    });