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

expect(Infinity).toBeCloseTo(Infinity) fails #7405

Closed
nampord opened this issue Nov 24, 2018 · 14 comments
Closed

expect(Infinity).toBeCloseTo(Infinity) fails #7405

nampord opened this issue Nov 24, 2018 · 14 comments

Comments

@nampord
Copy link

nampord commented Nov 24, 2018

For consistency it would be good if .toBeCloseTo could handle Infinity gracefully :

any number should not be close to Infinity at any precision
Infinity should be close to Infinity at any precision

any number should not be close to -Infinity at any precision
-Infinity should be close to -Infinity at any precision

-Infinity should not be close to Infinity at any precision

@thymikee
Copy link
Collaborator

Mind sending a PR with this enhancement? :)

@michaeldera
Copy link

This could be something I'd like to do

@pbondoer
Copy link

@michaeldera Are you working on this? I'd like to do this as my first PR ✨

@michaeldera
Copy link

No I am not, you can go ahead and have a go at it @pbondoer

@rickhanlonii
Copy link
Member

@pbondoer happy to hear! Check out the contributing guide here and lmk if you have any questions 👍

@Sharcoux
Copy link

Is really infinity close to infinity??
Mathematically speaking this is stupid. n^2 and n tends to be less and less close to each other when n tends to infinity... Some infinities are much bigger than others.

@michaeldera
Copy link

I think that was the point of the issue @Sharcoux

@rickhanlonii
Copy link
Member

rickhanlonii commented Nov 29, 2018

Good point @Sharcoux, but I think as at a programming API level, people expect .toBeCloseTo to include anything that is isEqual and the global Infinity is equal to itself irrespective of the character of infinity it's representing

@joao-conde
Copy link

I have a solution for this issue ready to go, but I've noticed I did not announce my intent to solve this issue, so @pbondoer is probably on it. Even so, since I solved it, may I PR?

@rickhanlonii
Copy link
Member

@joao-conde I'd say go ahead and submit it

@SimenB
Copy link
Member

SimenB commented Dec 2, 2018

Fixed by #7444

@SimenB SimenB closed this as completed Dec 2, 2018
@pbondoer
Copy link

Hey @joao-conde, thanks for submitting the PR. I had some personal stuff to take care of and couldn't get to it. Good thing you did! 👍

@joao-conde
Copy link

No problem, hope everything's sorted out for you!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants