Skip to content

Commit

Permalink
assert: fix deepEqual RangeError: Maximum call stack size exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
rmdm committed May 30, 2017
1 parent bb91879 commit f299cfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ function _deepEqual(actual, expected, strict, memos) {

const actualPosition = memos.actual.map.get(actual);
if (actualPosition !== undefined) {
if (actualPosition === memos.expected.map.get(expected)) {
return true;
}
return actualPosition === memos.expected.map.get(expected);
} else {
memos.actual.map.set(actual, memos.actual.position++);
}
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,18 @@ a.throws(makeBlock(thrower, TypeError), function(err) {

a.throws(makeBlock(a.deepEqual, d, e), /AssertionError/);
a.throws(makeBlock(a.deepStrictEqual, d, e), /AssertionError/);

// https://github.com/nodejs/node/issues/13314
const f = {};
f.ref = f;

const g = {};
g.ref = g;

const h = {ref: g};

a.throws(makeBlock(a.deepEqual, f, h), /AssertionError/);
a.throws(makeBlock(a.deepStrictEqual, f, h), /AssertionError/);
}
// GH-7178. Ensure reflexivity of deepEqual with `arguments` objects.
const args = (function() { return arguments; })();
Expand Down

0 comments on commit f299cfa

Please sign in to comment.