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

Test when min == max #26

Closed
Richienb opened this issue Mar 27, 2024 · 3 comments
Closed

Test when min == max #26

Richienb opened this issue Mar 27, 2024 · 3 comments

Comments

@Richienb
Copy link
Contributor

(theoretically) If they are equal then the previous value will always be the same, so the program enters an infinite loop.

I think it is a better fix to make it work with only one number anyways, as opposed to throwing an error since this could happen if min and max are generated by another source.

@Richienb
Copy link
Contributor Author

Richienb commented Mar 27, 2024

Nevermind, this issue is dealt with, but there are no tests.

previousValue = (number === previousValue && minimum !== maximum) ? random() : number;

@Richienb Richienb changed the title Crash when min == max Test when min == max Mar 27, 2024
@Richienb
Copy link
Contributor Author

How bad is it that we're outputting the same number in a row in a package where we say that we don't do that?

@sindresorhus
Copy link
Owner

I would say that should be expected when only one number is possible, but I think we should document that just to cover our bases, and obviously add a test for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants