Skip to content

check(...).deepEquals(...) fails to describe a large-ish Map #2441

Closed
@matanlurey

Description

@matanlurey

I am not 100% sure of the cause of the failure (yet), but it can be reproduced with the following test case:

test('can be described failing compared to another large map', () {
  const expected = {
    1: -5,
    2: -4,
    3: -4,
    4: -3,
    5: -3,
    6: -2,
    7: -2,
    8: -1,
    9: -1,
    10: 0,
    11: 0,
    12: 1,
    13: 1,
    14: 2,
    15: 2,
    16: 3,
    17: 3,
    18: 4,
    19: 4,
    20: 5,
    21: 5,
    22: 6,
    23: 6,
    24: 7,
    25: 7,
    26: 8,
    27: 8,
    28: 9,
    29: 9,
    30: 10,
  };
  final actual = {
    1: -4,
    2: -4,
    3: -3,
    4: -3,
    5: -2,
    6: -2,
    7: -1,
    8: -1,
    9: 0,
    10: 0,
    11: 0,
    12: 1,
    13: 1,
    14: 2,
    15: 2,
    16: 3,
    17: 3,
    18: 4,
    19: 4,
    20: 5,
    21: 5,
    22: 6,
    23: 6,
    24: 7,
    25: 7,
    26: 8,
    27: 8,
    28: 9,
    29: 9,
    30: 10
  };
  check(actual).not((a) => a.deepEquals(expected));
});

The failure will look like this:

type 'List<Iterable<String>>' is not a subtype of type 'Iterable<List<String>>' of 'newContents'
dart:collection                                ListBase.replaceRange
package:checks/src/describe.dart 75:14         _prettyPrintCollection
package:checks/src/describe.dart 54:12         _prettyPrint
package:checks/src/describe.dart 17:45         literal
package:checks/src/checks.dart 1006:27         Rejection._fillActual
package:checks/src/checks.dart 706:53          _TestContext.expect.<fn>
package:checks/src/checks.dart 594:65          _Present.apply
package:checks/src/checks.dart 706:16          _TestContext.expect
package:checks/src/extensions/map.dart 103:12  MapChecks.deepEquals
test/extensions/map_test.dart 97:32            main.<fn>.<fn>
package:checks/src/checks.dart 117:12          softCheck
package:checks/src/extensions/core.dart 53:13  CoreChecks.not.<fn>
package:checks/src/checks.dart 706:43          _TestContext.expect.<fn>
package:checks/src/checks.dart 594:65          _Present.apply
package:checks/src/checks.dart 706:16          _TestContext.expect
package:checks/src/extensions/core.dart 50:13  CoreChecks.not
test/extensions/map_test.dart 97:19            main.<fn>

If I can fix the problem, I'll suggest a patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    package:checksIssues related to pkg:checkstype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions