-
Notifications
You must be signed in to change notification settings - Fork 7.3k
assert.deepEqual() does not stop on circular references #207
Comments
I had the same problem in my test suite. I edited node.js to fix the problem : http://github.com/strager/node/commit/56dbd80eb883641e0fa734bd9f91be5d680feb54 |
Better: set a non-enumerable property $id on the object, and add the id to an object that belongs to the equal call. So the check, if an object was already checked, will be faster. |
@akidee, I think this would cause problems. I prefer a "hands-off" approach; don't touch the object, but just examine it. If you can do some performance analysis and it proves your method to be significantly faster or my method to be very flawed, we could reconsider, but I prefer correctness and fool-proof-ness over performance when writing test cases. (I REALLY don't want bugs or gatcha's in the assertion framework I'm using!) |
I appreciate a "hands-off" approach. I use my method for fast validation of objects. But you are right: in a test case you want to be fool-proof. So it would be good to get your patch pushed to the main branch. |
Alright ... Do I have to wait for a committer to see this or should I e-mail or something? (I don't github that much.) |
You have made a fork of node, so simply send ry a pull request (button on the top right hand side) |
Any success? |
appears to be working in current version v0.4.3. Reopen if broke. |
Add test for circular refs in deepEquals Closed by 6394ba2. |
The script will not output 'All OK':
var b = {};
b.b = b;
var c = {};
c.b = c;
assert.deepEqual(b, c);
sys.puts('All OK');
The text was updated successfully, but these errors were encountered: