Skip to content

Conversation

@cjihrig
Copy link
Contributor

The docs for assert.deepStrictEqual() do not currently mention that prototypes are compared for objects. This commit adds that information to the documentation.

Fixes: #5365

The docs for assert.deepStrictEqual() do not currently mention that prototypes are compared for objects. This commit adds that information to the documentation. Fixes: nodejs#5365
@r-52r-52 added assert Issues and PRs related to the assert subsystem. doc Issues and PRs related to the documentations. lts-watch-v4.x labels Feb 22, 2016
@cjihrig
Copy link
ContributorAuthor

R=@nodejs/documentation

@eljefedelrodeodeljefe
Copy link
Contributor

LGTM

@benjamingr
Copy link
Member

I'm not sure I would understand what "object prototypes are included in the comparison" means - it might imply they need to have the same __proto__.

@cjihrig
Copy link
ContributorAuthor

What about this?

Generally identical to `assert.deepEqual()` with two exceptions. First, primitive values are compared using the strict equality operator ( `===` ). Second, object comparisons include a strict equality check of their prototypes. 

@benjamingr
Copy link
Member

That might still imply that their prototypes are checked and are expected to be equal (is that the case?) - what about:

Generally identical to assert.deepEqual() with two exceptions. First, primitive values
are compared using the strict equality operator ( === ). Second, object comparisons
include a strict equality check of properties on their prototypes.

@cjihrig
Copy link
ContributorAuthor

It's actually a strict comparison of the prototypes. https://github.com/nodejs/node/blob/master/lib/assert.js#L199

@benjamingr
Copy link
Member

@cjihrig Oh, in that case my bad - LGTM

values are compared using the strict equality operator ( `===` ).
Generally identical to [`assert.deepEqual()`][] with the exceptions that
primitive values are compared using the strict equality operator ( `===` ), and
object prototypes are included in the comparison.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object prototypes are included in the comparison.

seems a little vague to me.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See proposed change in the main thread.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would have been better if we could somehow say that prototypes should be the same. But yeah the proposed change also is okay.

@thefourtheye
Copy link
Contributor

LGTM

@cjihrig
Copy link
ContributorAuthor

Thanks for the reviews. Landed in 10f55b0.

@cjihrigcjihrig closed this Feb 23, 2016
@cjihrigcjihrig deleted the 5365 branch February 23, 2016 14:21
@Fishrock123Fishrock123 mentioned this pull request Mar 1, 2016
5 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assertIssues and PRs related to the assert subsystem.docIssues and PRs related to the documentations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@cjihrig@eljefedelrodeodeljefe@benjamingr@thefourtheye@MylesBorins@r-52