-
-
Notifications
You must be signed in to change notification settings - Fork 697
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
NaN assertion is not strict enough #498
Labels
Comments
Lets make the breaking change - as you say, its useless if it throws up false positives. There's a 4.x.x branch which you can make a PR into. When we release 4.0.0 we can release it with the breaking change 😄 |
Closed
thefourtheye
pushed a commit
to thefourtheye/chai
that referenced
this issue
Aug 19, 2015
thefourtheye
added a commit
to thefourtheye/chai
that referenced
this issue
Aug 19, 2015
This is fixed in cbfb6fd (in the |
Thanks again @berkerpeksag 😄 |
lucasfcosta
pushed a commit
to lucasfcosta/chai
that referenced
this issue
Mar 14, 2016
lucasfcosta
pushed a commit
to lucasfcosta/chai
that referenced
this issue
Mar 14, 2016
meeber
pushed a commit
to meeber/chai
that referenced
this issue
Sep 5, 2016
meeber
pushed a commit
to meeber/chai
that referenced
this issue
Sep 8, 2016
lucasfcosta
pushed a commit
to lucasfcosta/chai
that referenced
this issue
Sep 15, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NaN was recently hopefully recently added.
But because it relies on the global isNaN() function, it has the same flaws : because isNan() converts its argument before testing, it returns true in many unexpected cases, and false in others. It is not very predictible (i.e. isNan("bla") returns true, but isNaN("") returns false).
ES6 introduces Number.isNaN() which behaves as intuitively expected : if the value is a NaN, it returns true, otherwise (strings, dates...), it returns false. A very short polyfill for ES5 is proposed in the MDN documentation.
A strict isNaN is really needed. I can see 2 options :
I really think current isNaN() implementation is nearly useless, so I prefer the first option.
If the preferred way is option 2, then option 2.1 feels more like in the spirit of chai, which has different predicates for loose and strict versions of the same predicate (above/least, below/most, equal/eql).
I'm OK to do the job when this discussion will be closed.
The text was updated successfully, but these errors were encountered: