diff --git a/pkgs/checks/CHANGELOG.md b/pkgs/checks/CHANGELOG.md index 6588352e9..52f4c3e78 100644 --- a/pkgs/checks/CHANGELOG.md +++ b/pkgs/checks/CHANGELOG.md @@ -8,6 +8,8 @@ - Add `containsMatchingInOrder` and `containsEqualInOrder` to replace the combined functionality in `containsInOrder`. - Replace `pairwiseComparesTo` with `pairwiseMatches`. +- Fix a bug where printing the result of a failed deep quality check would + fail with a `TypeError` when comparing large `Map` instances - Increase SDK constraint to ^3.5.0. ## 0.3.0 diff --git a/pkgs/checks/lib/src/describe.dart b/pkgs/checks/lib/src/describe.dart index f05a1640b..ab0b2898b 100644 --- a/pkgs/checks/lib/src/describe.dart +++ b/pkgs/checks/lib/src/describe.dart @@ -72,7 +72,11 @@ Iterable _prettyPrint( Iterable _prettyPrintCollection( String open, String close, List> elements, int maxLength) { if (elements.length > _maxItems) { - elements.replaceRange(_maxItems - 1, elements.length, [ + // Force inference as List, otherwise the type is + // List> which ends up as a type error in dart:collection + // when the underlying list is actually a List>. See + // https://github.com/dart-lang/test/issues/2441 for more details. + elements.replaceRange(_maxItems - 1, elements.length, >[ ['...'] ]); } diff --git a/pkgs/checks/test/extensions/map_test.dart b/pkgs/checks/test/extensions/map_test.dart index cb3e3e493..6cc3f5064 100644 --- a/pkgs/checks/test/extensions/map_test.dart +++ b/pkgs/checks/test/extensions/map_test.dart @@ -29,6 +29,65 @@ void main() { test('values', () { check(_testMap).values.contains(1); }); + 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, + }; + 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, + }; + check(actual).not((a) => a.deepEquals(expected)); + }); group('operator []', () { test('succeeds for a key that exists', () {