|
@ -143,7 +143,7 @@ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
function _deepEqual(actual, expected, strict) { |
|
|
function _deepEqual(actual, expected, strict, memos) { |
|
|
// 7.1. All identical values are equivalent, as determined by ===.
|
|
|
// 7.1. All identical values are equivalent, as determined by ===.
|
|
|
if (actual === expected) { |
|
|
if (actual === expected) { |
|
|
return true; |
|
|
return true; |
|
@ -191,7 +191,19 @@ function _deepEqual(actual, expected, strict) { |
|
|
// corresponding key, and an identical 'prototype' property. Note: this
|
|
|
// corresponding key, and an identical 'prototype' property. Note: this
|
|
|
// accounts for both named and indexed properties on Arrays.
|
|
|
// accounts for both named and indexed properties on Arrays.
|
|
|
} else { |
|
|
} else { |
|
|
return objEquiv(actual, expected, strict); |
|
|
memos = memos || {actual: [], expected: []}; |
|
|
|
|
|
|
|
|
|
|
|
const actualIndex = memos.actual.indexOf(actual); |
|
|
|
|
|
if (actualIndex !== -1) { |
|
|
|
|
|
if (actualIndex === memos.expected.indexOf(expected)) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
memos.actual.push(actual); |
|
|
|
|
|
memos.expected.push(expected); |
|
|
|
|
|
|
|
|
|
|
|
return objEquiv(actual, expected, strict, memos); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -199,7 +211,7 @@ function isArguments(object) { |
|
|
return Object.prototype.toString.call(object) == '[object Arguments]'; |
|
|
return Object.prototype.toString.call(object) == '[object Arguments]'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function objEquiv(a, b, strict) { |
|
|
function objEquiv(a, b, strict, actualVisitedObjects) { |
|
|
if (a === null || a === undefined || b === null || b === undefined) |
|
|
if (a === null || a === undefined || b === null || b === undefined) |
|
|
return false; |
|
|
return false; |
|
|
// if one is a primitive, the other must be same
|
|
|
// if one is a primitive, the other must be same
|
|
@ -235,7 +247,8 @@ function objEquiv(a, b, strict) { |
|
|
//~~~possibly expensive deep test
|
|
|
//~~~possibly expensive deep test
|
|
|
for (i = ka.length - 1; i >= 0; i--) { |
|
|
for (i = ka.length - 1; i >= 0; i--) { |
|
|
key = ka[i]; |
|
|
key = ka[i]; |
|
|
if (!_deepEqual(a[key], b[key], strict)) return false; |
|
|
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|