Skip to content

Commit

Permalink
assert: don't compare object prototype property
Browse files Browse the repository at this point in the history
All own enumerable properties are compared already. Comparing
`prototype` property specifically can cause weird behaviour.

PR-URL: #636
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
vkurchatkin committed Feb 6, 2015
1 parent 8d11799 commit e7573f9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ function isArguments(object) {
function objEquiv(a, b) {
if (a === null || a === undefined || b === null || b === undefined)
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
// if one is a primitive, the other must be same
if (util.isPrimitive(a) || util.isPrimitive(b))
return a === b;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ assert.doesNotThrow(makeBlock(a.deepEqual, nb1, nb2));

nameBuilder2.prototype = Object;
nb2 = new nameBuilder2('Ryan', 'Dahl');
assert.throws(makeBlock(a.deepEqual, nb1, nb2), a.AssertionError);
assert.doesNotThrow(makeBlock(a.deepEqual, nb1, nb2));

// primitives and object
assert.throws(makeBlock(a.deepEqual, null, {}), a.AssertionError);
Expand Down

0 comments on commit e7573f9

Please sign in to comment.