Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't test for runtimeType equality for object comparison #188

Closed
wants to merge 1 commit into from
Closed
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: 0 additions & 2 deletions lib/src/equatable_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ bool objectsEquals(Object? a, Object? b) {
return iterableEquals(a, b);
} else if (a is Map && b is Map) {
return mapEquals(a, b);
} else if (a?.runtimeType != b?.runtimeType) {
return false;
} else if (a != b) {
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions test/equatable_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ void main() {
expect(objectsEquals(bob, alice), isFalse);
});

test('returns true for int and double in a num variable', () {
const num intNum = 0;
const num doubleNum = 0.0;
expect(objectsEquals(intNum, doubleNum), isTrue);
});

test('returns true for same lists', () {
expect(objectsEquals([1, 2, 3], [1, 2, 3]), isTrue);
});
Expand Down