matcher
matcher copied to clipboard
FR: Possible to customise the equals() matcher to use closeTo()
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 ==.