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

FR: Possible to customise the equals() matcher to use closeTo() #2407

Open
bramp opened this issue Mar 30, 2024 · 0 comments
Open

FR: Possible to customise the equals() matcher to use closeTo() #2407

bramp opened this issue Mar 30, 2024 · 0 comments

Comments

@bramp
Copy link

bramp commented Mar 30, 2024

I quite often have objects that include a double, and use a deep matcher (via equals()), e.g

import 'dart:math';

List<Point<double>> a = resultOfSomeFunction();

expect(a, equals([Point<double>(1.2, 3.4), ...]);

In this case, I want to compare a list of Point<double>, but sometimes the test fails, because the double precision, and I really should compare the numbers with closeTo() instead of a simple ==.

Would it be possible to customise equals() so when it does a deep comparison, the individual values can be compared with a different matcher.

Something like, equals([Point<double>(1.2, 3.4), ...], matcher=closeTo)? Until then, I've effectively forked the equals/_DeepMatcher and replaced one line with a closeTo() instead of a ==.

@mosuem mosuem transferred this issue from dart-archive/matcher Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants