Open Bug 1074049 Opened 5 years ago Updated 5 years ago

Assert.deepEqual does not work properly with NaN values

Categories

(Testing :: General, defect)

defect
Not set

Tracking

(Not tracked)

People

(Reporter: jcranmer, Unassigned)

References

Details

... maybe?

I've been testing a lot of my development code in a separate repository using browser tests that relied on chai for its testing assertions <https://github.com/chaijs/chai/>. Upon importing to comm-central and using Assert.jsm for the assert.* methods, I've noticed that a test which passes using chai fails. It effectively boils down to:

assert.deepEqual({size: NaN}, {size: NaN}).

It's not clear to me from any documentation what the expected behavior should be, although lots of vague references to "== kind of equality", and it looks like the behavior I'm getting comes from <https://github.com/chaijs/chai/commit/8fd42281210d0d92effdf0ed110056590f76e364>.

I'm not sure what's proper interoperable behavior because no one ever appears to give a sufficiently precise definition of these things. There aren't even test-based descriptions of what should happen in the test suites of utility libraries for writing test-based descriptive tests. o_O
I see what you mean! It's indeed unfortunate that this things are undocumented. The link to the chai commit did give me some more insight, though, as I started reading the deep-eql module:

https://github.com/chaijs/deep-eql/blob/master/lib/eql.js#L71

So what we could do is integrate that behavior properly into Assert.jsm... I think that'd be best.
OS: Linux → All
Hardware: x86_64 → All
You need to log in before you can comment on or make changes to this bug.