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

Feature/3099 nan tolerance #3240

Closed
wants to merge 3 commits into from

Conversation

piotrb5e3
Copy link

Hi,

This is a proposed solution to #3099.

I unified the code of all tolerance matchers and improved handling around NaNs.

It has one issue: since the new code operates all on doubles, the old "Match close enough numbers" test fails, as the ranges of acceptable values are slightly different with double rounding. Not really sure what to do about it.

I'd also happily remove FloatToleranceMatcher, but I'm not sure if it's not part of the API.

import io.kotest.matchers.MatcherResult
import kotlin.math.abs

open class ToleranceMatcher<T : Number>(private val expected: T, private val tolerance: Double) : Matcher<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting solution by using Number!

@sksamuel sksamuel self-requested a review December 5, 2022 00:14
@sksamuel sksamuel enabled auto-merge (squash) December 5, 2022 00:14
@stale
Copy link

stale bot commented Jan 5, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale 🏚️ Issues that were lost to time and are no longer up-to-date label Jan 5, 2023
@stale stale bot removed the stale 🏚️ Issues that were lost to time and are no longer up-to-date label Jan 15, 2023
@sksamuel
Copy link
Member

Just need to fix the test @piotrb5e3 and I think we're good!

@Kantis
Copy link
Member

Kantis commented Feb 13, 2023

In my opinion we should revert the unification of ToleranceMatchers. It'll lead to some duplicate code, but it will let us be as correct as possible which I think is more important.

@sksamuel
Copy link
Member

I agree

@stale
Copy link

stale bot commented Mar 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale 🏚️ Issues that were lost to time and are no longer up-to-date label Mar 18, 2023
@stale stale bot closed this Mar 25, 2023
auto-merge was automatically disabled March 25, 2023 12:52

Pull request was closed

@sksamuel sksamuel reopened this Mar 25, 2023
@stale stale bot removed the stale 🏚️ Issues that were lost to time and are no longer up-to-date label Mar 25, 2023
@LeoColman
Copy link
Member

@piotrb5e3 Could you give maintainers access to your branch so we can fix the git history?

@piotrb5e3
Copy link
Author

@LeoColman Should I add specific people to the access list for this branch? Allow edits by maintainers is already enabled.

@stale
Copy link

stale bot commented Jun 17, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale 🏚️ Issues that were lost to time and are no longer up-to-date label Jun 17, 2023
@stale stale bot closed this Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale 🏚️ Issues that were lost to time and are no longer up-to-date
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants