Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/matcher/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Add `isSorted` and related matchers for iterables.
* Consider `NaN` to be equal to itself in `equals`.
* Allow exceptions from `operator ==` to bubble up and fail the test instead of
treating them as unequal objects.
* Remove some dynamic invocations.
* Add explicit casts from `dynamic` values.
* Require Dart 3.7
Expand Down
22 changes: 6 additions & 16 deletions pkgs/matcher/lib/src/equals_matcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,12 @@ class _DeepMatcher extends Matcher {
});
} else {
// Otherwise, test for equality, or both values NaN
try {
if (expected == actual ||
(expected is num &&
expected.isNaN &&
actual is num &&
actual.isNaN)) {
return null;
}
} catch (e) {
// TODO(gram): Add a test for this case.
return _Mismatch(
location,
actual,
(description, verbose) =>
description.add('== threw ').addDescriptionOf(e),
);
if (expected == actual ||
(expected is num &&
expected.isNaN &&
actual is num &&
actual.isNaN)) {
return null;
}
}

Expand Down
Loading