-
Notifications
You must be signed in to change notification settings - Fork 7.3k
assert.deepEqual has bad test #4523
Comments
The simplest possible demonstration that this is a bug is that this doesn't throw: var assert = require('assert')
assert.deepEqual([], {}) |
If you submit a pull request and include regression tests, I'll merge it. |
will do. |
It most likely should be: if (a.__proto__ !== b.__proto__) return false; |
@medikoo Though |
@Lewuathe if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false; |
Oh, sorry, lack my knowledge. Thanks @medikoo. |
If you fix this, you break https://github.com/joyent/node/blob/master/test/simple/test-assert.js#L115 😖 |
That's especially bad considering the API is locked |
Yeah, even if they do have a "prototype" prop, then it'll check later Patch welcome. On Friday, April 12, 2013, Ryan Doenges wrote:
|
Uh oh, removing 😦 |
Uhm, looks like this is still broken? What happened? |
I just noticed that this does NOT throw: assert.deepEqual(Object.create({tea:'chai'}), Object.create({tea:'black'})) Weird. |
This is a shortcoming of |
Can't reproduce in node v0.12.3, any need to keep this issue open? |
At this point someone could take the step of backporting nodejs/node@3f473ef to v0.12 if they feel it's necessary. But given that this is addressed in v3.x, I'm inclined to close this. Can reopen if necessary. |
If you look at https://github.com/joyent/node/blob/master/lib/assert.js#L208-L209
is incorrect.
a
andb
are instances, not constructor functions, and as such, will never have prototypes set directly on them. Similar deep equality tests do the following instead:objEquiv
should probably be changed similarly, although a case could be made that this test could be junked, seeing as how this hasn't been noticed until now.The text was updated successfully, but these errors were encountered: