Skip to content

Commit

Permalink
assert: avoid potentially misleading reference to object identity
Browse files Browse the repository at this point in the history
Often, the word “identical” when referring to JS objects will
be read as referring to having the same object identity (which is
called “reference equality” here), but what the error message is
trying to say here is that the objects are different but yield the
same `util.inspect()` output.

Since `util.inspect()` output represents the structure rather than
the identity of objects, (hopefully) clarify the error message to
reflect that.

PR-URL: nodejs#28824
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
addaleax authored and Trott committed Jul 26, 2019
1 parent 48e13d2 commit 64e4b0c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/internal/assert/assertion_error.js
Expand Up @@ -22,7 +22,7 @@ const kReadableOperator = {
notStrictEqualObject:
'Expected "actual" not to be reference-equal to "expected":',
notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:',
notIdentical: 'Values identical but not reference-equal:',
notIdentical: 'Values have same structure but are not reference-equal:',
notDeepEqualUnequal: 'Expected values not to be loosely deep-equal:'
};

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-assert.js
Expand Up @@ -1101,7 +1101,7 @@ assert.throws(() => { throw null; }, 'foo');
assert.throws(
() => assert.strictEqual([], []),
{
message: 'Values identical but not reference-equal:\n\n[]\n'
message: 'Values have same structure but are not reference-equal:\n\n[]\n'
}
);

Expand Down

0 comments on commit 64e4b0c

Please sign in to comment.