Uh oh!
There was an error while loading. Please reload this page.
lib: generalize handling in assert.deepEqual() - #3124
Conversation
thefourtheye
commented
Sep 30, 2015
Whenever there is a change suggested in this module I judge that by this comment #2315 (comment). If we go by that, this change is not necessary as assert is not a general purpose module. |
ChALkeR
commented
Sep 30, 2015
Is this a semver-major? @rvagg |
Trott
commented
Sep 30, 2015
@thefourtheye Yes, if that's the standard, then this is probably not necessary. I say "probably" because I wonder if any of the checks on things like More importantly, perhaps: If the |
ChALkeR
commented
Sep 30, 2015
@Trott, @domenic It's a bit too late for making the It's directly used by at least 11% of modules on npmjs (a quick grep for Update: Without the |
rvagg
commented
Sep 30, 2015
Yes, has to be semver-major I reckon, also I'm not sure this approach is consistent, have a look at how |
Fishrock123
commented
Oct 7, 2015
JavaScript is an awful language sometimes haha. I agree with Rod's sentiment, but I think the frequency of use would warrant this enough. If nothing else, we could probably get it into |
Trott
commented
Oct 8, 2015
I'm thinking I should close this PR and instead update the docs to reflect that:
|
866e5f8 to
c8855dbCompareTrott
commented
Oct 10, 2015
@rvagg, @Fishrock123: Since it's already semver-major, might an appropriate course of action be to run RegExp (and maybe a few other things) through this more rigorous checking? Assuming it doesn't bork any of our tests, it seems like that might streamline the code a bit. It's semver-major already, so why not take the opportunity to streamline the code a bit? |
Trott
commented
Oct 11, 2015
Just pushed something to remove special handling for Error, Buffer, and RegExp. Added a tiny bit of hopefully-straightforward special handling for Array and String (which is to ignore the length property if they are being compared against something that doesn't have a length property). All tests still pass. Still semver major, but I feel much better about this. Seems less hacky. PTAL @rvagg@Fishrock123 Still could use a doc update to clarify some finer points, but that could be a separate PR, as this is all consistent with existing docs. |
32009e7 to
f7fe2ccCompareTrott
commented
Oct 11, 2015
rvagg
commented
Oct 12, 2015
yeah, I don't know, this is pretty significant, perhaps we need to include @nodejs/tsc on this for more opinions |
trevnorris
commented
Oct 12, 2015
This PR looks like it's attempting to achieve some sort of theoretical completeness. Which I don't disagree with, but on this route you must seriously consider also doing proper comparisons of any |
Error objects have non-enumerable properties. So, unexpectedly,
assert.deepEqual(new Error('a'), new Error('b')) will not throw an
AssertionError. This commit changes that behavior.
Fixes: nodejs#3122f7fe2cc to
a5b09a5CompareTrott
commented
Oct 12, 2015
@trevnorris Symbols added. Thanks for that! |
domenic
commented
Oct 12, 2015
This seems better to me.
Nobody suggested making it internal or deprecating it. Just, not changing it. |
Trott
commented
Oct 12, 2015
@domenic Can you elaborate a bit on why you favor the doc-only approach but not a deprecation? I'm assuming deprecation could just mean sticking a deprecation notice in the docs but not doing anything at all in the code. Maybe we just have different ideas about what "deprecation" might entail. The close-in-favor-of-doc-PR was how I felt when this change was adding additional special handling for |
Trott
commented
Oct 12, 2015
domenic
commented
Oct 12, 2015
I just think that contributors and core team members should not spend time working on the assert module. They especially shouldn't be doing so in a way that changes behavior in observable ways that could break programs using it. Maybe it would be helpful to add something to the docs saying its behavior won't be changed, so that people don't file issues on it. And maybe it'd even be interesting to explain why---because the assert module is developed so that Node.js can test itself, not so that you can write your own tests. I don't know if you'd call that a deprecation or not. |
Trott
commented
Oct 12, 2015
@domenic Thanks, that's very clear. I guess regardless of what happens to this PR, the doc change is a good idea. |
Trott
commented
Oct 12, 2015
Proposed doc-only update at #3330. I'm still in favor of the changes here, but regardless, the docs should reflect the current status. |
Trott
commented
Oct 16, 2015
Based on the audio from the most recent TSC meeting, I'm going to close this PR. |
Assert is now locked. Userland alternatives should be used. Assert is for testing Node.js itself. Document potentially surprising use of enumerable properties only in deep equality assertions. Ref: nodejs#3124 Ref: nodejs#3122 PR-URL: nodejs#3330 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Assert is now locked. Userland alternatives should be used. Assert is for testing Node.js itself. Document potentially surprising use of enumerable properties only in deep equality assertions. Ref: #3124 Ref: #3122 PR-URL: #3330 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Assert is now locked. Userland alternatives should be used. Assert is for testing Node.js itself. Document potentially surprising use of enumerable properties only in deep equality assertions. Ref: #3124 Ref: #3122 PR-URL: #3330 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Assert is now locked. Userland alternatives should be used. Assert is for testing Node.js itself. Document potentially surprising use of enumerable properties only in deep equality assertions. Ref: #3124 Ref: #3122 PR-URL: #3330 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Errorobjects have non-enumerable properties. So, unexpectedly,assert.deepEqual(new Error('a'), new Error('b'));will not throw. Thiscommit changes that behavior.
Fixes: #3122