Skip to content

Commit

Permalink
passing new tests yay
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Jun 7, 2011
1 parent 73efbe5 commit 3d5057a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ Traverse.prototype.deepEqual = function (obj) {
return undefined;
}).bind(this);

//if (node === undefined || node === null) return notEqual();

if (!this.isRoot) {
/*
if (!Object.hasOwnProperty.call(node, this.key)) {
return notEqual();
}
*/
if (typeof node !== 'object') return notEqual();
node = node[this.key];
}

Expand All @@ -84,6 +87,9 @@ Traverse.prototype.deepEqual = function (obj) {
else if (typeof x !== typeof y) {
notEqual();
}
else if (x === null || y === null || x === undefined || y === undefined) {
if (x !== y) notEqual();
}
else if (x.__proto__ !== y.__proto__) {
notEqual();
}
Expand All @@ -98,10 +104,7 @@ Traverse.prototype.deepEqual = function (obj) {
else if (x !== y) notEqual();
}
else if (typeof x === 'object') {
if (x === null || y === null) {
if (x !== y) notEqual();
}
else if (toS(y) === '[object Arguments]'
if (toS(y) === '[object Arguments]'
|| toS(x) === '[object Arguments]') {
if (toS(x) !== toS(y)) {
notEqual();
Expand Down
3 changes: 3 additions & 0 deletions test/equal.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ exports.deepUn = function () {
assert.ok(!traverse.deepEqual({ a : 1, b : 2 }, {}));
assert.ok(!traverse.deepEqual(undefined, { a : 1, b : 2 }));
assert.ok(!traverse.deepEqual({}, { a : 1, b : 2 }));
assert.ok(traverse.deepEqual(undefined, undefined));
assert.ok(traverse.deepEqual(null, null));
assert.ok(!traverse.deepEqual(undefined, null));
};

exports.deepLevels = function () {
Expand Down

0 comments on commit 3d5057a

Please sign in to comment.