Uh oh!
There was an error while loading. Please reload this page.
assert: don't compare object prototype property - #636
Conversation
seishun
commented
Jan 28, 2015
IMO if we're going to deviate from CommonJS spec, then the docs for |
vkurchatkin
commented
Jan 28, 2015
This is how they do it in ringo: https://github.com/ringo/ringojs/blob/f06dd6d0c235a0c22fc50ec6ca59209e560da396/modules/assert.js#L92 |
vkurchatkin
commented
Feb 1, 2015
Can anyone review this? @chrisdickinson or @cjihrig maybe? |
seishun
commented
Feb 1, 2015
A comment in the source code doesn't really cut it. |
vkurchatkin
commented
Feb 1, 2015
@seishun it's not a about the comment. Some facts:
|
cjihrig
commented
Feb 1, 2015
The code looks fine, but this goes against what I would consider "deep equal." I think a larger conversation needs to happen around the |
vkurchatkin
commented
Feb 1, 2015
Can you elaborate? Do you mean this particular change or overall |
seishun
commented
Feb 1, 2015
It doesn't explain what "deep equality" means either, which makes it "obvious" that it uses the algorithm from the buggy and dead spec. Let's not follow ringojs in confusing users even more. |
cjihrig
commented
Feb 1, 2015
I mean that I would expect a |
vkurchatkin
commented
Feb 1, 2015
rvagg
commented
Feb 1, 2015
I'm not comfortable providing sign-off on this, I'm more of a -0 on this @vkurchatkin do you see this as a necessary part of #639? |
vkurchatkin
commented
Feb 1, 2015
@rvagg no, I don't. But since they share implementation |
vkurchatkin
commented
Feb 4, 2015
As discussed at TC meeting, CommonJS spec is not relevant anymore. I will land this as soon as I see a couple of LGTMs. |
There was a problem hiding this comment.
Minus , a.AssertionError and perhaps drop the assert.doesNotThrow call entirely? The exception can just bubble up.
bnoordhuis
commented
Feb 5, 2015
Left a comment. Otherwise LGTM. |
All own enumerable properties are compared already. Comparing `prototype` property specifically can cause weird behaviour.
3168b52 to
b0c697eComparevkurchatkin
commented
Feb 5, 2015
removed |
bnoordhuis
commented
Feb 5, 2015
I think that |
All own enumerable properties are compared already. Comparing `prototype` property specifically can cause weird behaviour. PR-URL: #636 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
vkurchatkin
commented
Feb 6, 2015
Thanks! landed in e7573f9 |
cjihrig
commented
Feb 6, 2015
In the last TC meeting, I think there was some discussion about holding off on this until 2.0.0. |
vkurchatkin
commented
Feb 6, 2015
I'm pretty sure it wasn't. There was some confusion with #621 though . That WAS a breaking change, this is merely a bugfix |
cjihrig
commented
Feb 6, 2015
OK, cool. Sorry for the confusion. |
Notable changes: * stream: - Simpler stream construction, see nodejs/readable-stream#102 for details. This extends the streams base objects to make their constructors accept default implementation methods, reducing the boilerplate required to implement custom streams. An updated version of readable-stream will eventually be released to match this change in core. (@sonewman) * dns: - `lookup()` now supports an `'all'` boolean option, default to `false` but when turned on will cause the method to return an array of *all* resolved names for an address, see, #744 (@silverwind) * assert: - Remove `prototype` property comparison in `deepEqual()`, considered a bugfix, see #636 (@vkurchatkin) - Introduce a `deepStrictEqual()` method to mirror `deepEqual()` but performs strict equality checks on primitives, see #639 (@vkurchatkin) * **tracing**: - Add LTTng (Linux Trace Toolkit Next Generation) when compiled with the `--with-lttng` option. Trace points match those available for DTrace and ETW. #702 (@thekemkid) * npm upgrade to 2.5.1 * **libuv** upgrade to 1.4.0 * Add new collaborators: - Aleksey Smolenchuk (@lxe) - Shigeki Ohtsu (@shigeki)
loveencounterflow
commented
Feb 13, 2015
May i add that i consider First of all, the API is horrible. Logically, either two things are equal or they're not, but As i try to show in jseq, the concept of 'equality' can lead to some hairy questions when it meets the reality of a language like JavaScript with its I suggest to introduce |
vkurchatkin
commented
Feb 13, 2015
I agree that non-strict equality is not really useful for assertions (or more like not useful at all). On the other hand, shallow equality is important. There is no way to know if objects should be treated as values or having identity. It is unlikely that something would be added (or removed) to |
loveencounterflow
commented
Feb 13, 2015
I fully understand the part where one wants to avoid breaking existing code and, therefore, keeps 'strange methods with strange behaviors' around and just adds new methods with 'better behavior'. Although if this principle is the only evolutional guideline then NodeJS will become ever more PHP-ish over the years ( I don't get where the difference between shallow and deep equality is important. This is really a semantic problem, and i guess where we can meet is saying that |
loveencounterflow
commented
Feb 14, 2015
@cjihrig "I mean that I would expect a deepEqual implementation to examine the prototype, either using === or a call to objEquiv()"—goes to show how hairy equality can become. I'd say that if some properties of all the properties |
All own enumerable properties are compared already. Comparing
prototypeproperty specifically can cause weird behaviour.an alternative to #621
Example:
The first assertion is ok, the second throws. It is unexpected and has no logical explanation.
Changed test was failing because of the following
nameBuilder2.prototype = Object;. Not sure if it is a mistake, or a test for CommonJS bug.R=@iojs/collaborators