kotest: ToleranceMatcher is unable to compare NaN doubles
Code:
Double.NaN shouldBe Double.NaN
Expected result: no errors, NaN == NaN
Actual result: java.lang.AssertionError: NaN should be equal to NaN
So, we have to have separate comparison for NaN values. JUnit does this - code below does not throw any exceptions:
assertEquals(Double.NaN, Double.NaN)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (14 by maintainers)
Commits related to this issue
- Added warning when tolerance matcher is used to compare Nan #214 — committed to kotest/kotest by sksamuel 7 years ago
Yes, you must either filter or handle NaN and Infinities.
The point in generators is that you’re saying “My program can handle absolutely any Double!” and both NaN and Infinities are valid doubles to be passed.
What we can discuss is if we should support out-of-the-box a matcher for “Numeric, non-corner-case Doubles”