Comments (11)
It seems that node core assert.deepEqual has the same bug. Here's how it behaves on node 5.1.0:
$ node -e "var a = new Set('a'), b = new Set('x'); require('assert').deepEqual(a, b)"
$ echo $?
0
from node-deep-equal.
Relevant node core discussion: nodejs/node#2309
This is a bit of a tricky decision, since node-deep-equal is meant to implement node's assert.deepEqual()
algorithm, but core has decided to lock its API and push handling new native data types in userland.
from node-deep-equal.
I guess it's ultimately up to you, @substack, whether you want to follow their lead or not. @domenic suggested that node's assert
module should only be used to test node, so it should be left as-is in core, and I agree. Until there's demand for it in core there's no need to include it there. It's not meant to be a general purpose assertion module.
In this package, however, I think you do have a little more flexibility.
For starters, in the assert
package they currently follow core's lead as well so anyone who wants node core behavior can just use require('assert').deepEqual
and it will work the same everywhere. If people show up here and complain that deepEqual
doesn't work the same as in node, you can just point them to the assert
package and tell them to use that if they want identical behavior.
Additionally, including support for more native data types here is an enhancement, so it won't break existing code.
If you rename the repo from node-deep-equal
to just deep-equal
(same as the package) then it should convey more clearly to users that this is a general purpose equality comparison, not just for node.
In any case, ultimately we'll need a deepEqual
library that knows about additional native types as they are added. They'll need it in core too, eventually.
Just a few thoughts. Hope it helps.
from node-deep-equal.
I'm not really sure in general that deepEqual is the right name for something that compares things based on their private state. You'd want something like "structurallyEqual" or "privateEqual" I think. Map, Set, Date, and Promise are all types which you could invent equality semantics for based on examining whether they have the same internal data, but "deep equal" traditionally means "has the same public properties" which will be true of any two Maps etc.
from node-deep-equal.
To sum things up: I need a way to write test assertions to compare the values in two ES2015 Sets. I really like @mjackson's expect
package, but I can use another package or build a helper comparison function if @substack doesn't want to support this; it just seems weird to me that there is no simple way to compare Sets, which are now native JavaScript objects 😜
cc: @statianzo
from node-deep-equal.
Update: We don't have this issue anymore in the expect package since we switched to https://github.com/ljharb/is-equal. Thanks for your time :)
from node-deep-equal.
@mjackson So I can compare Sets in the same way I compare arrays? Awesome! Thank you.
from node-deep-equal.
I encountered this problem using tape today. While the node team decided to take their ball and go home, it seems that tape (and this package) are left on the lonely playground they call "userland".
It's probably small-minded of me but I can't see a good reason a test assertion would want to find all Set objects "equal", and it sure would be nice if this library did the Right Thing rather than imitate its namesake's failings.
from node-deep-equal.
Scott, grow up. Your tone here is ridiculous.
On Fri, May 20, 2016 at 4:40 PM Scott Vachalek [email protected]
wrote:
I encountered this problem using tape today. While the node team decided
to take their ball and go home, it seems that tape (and this package) are
left on the lonely playground they call "userland".It's probably small-minded of me but I can't see a good reason a test
assertion would want to find all Set objects "equal", and it sure would be
nice if this library did the Right Thing rather than imitate its namesake's
failings.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#28 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAFqpzmVoAAzaCbwKDZ-BrlH94g5nqWrks5qDkZPgaJpZM4GpY59
.
from node-deep-equal.
My tone is light and playful, but sincere. I can switch testing and/or assertion libraries but before I do that, I would like to add a vote on the side of usefulness over semantics. If Set seems like too much of a special case, consider solving it for the iterable protocol.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable
from node-deep-equal.
Is there anything in the works for this? I'm doing deepEqual on something that contains a map, having to run my expected and result objects through something that unwraps a map into it's array version is rather cumbersome. Maybe a separate assertion that uses isEqual?
from node-deep-equal.
Related Issues (20)
- Feature request: point discrepancy that caused inequality HOT 2
- Weird Compare Fail HOT 11
- "regexp.prototype.flags": "^1.5.0" dependency is failing HOT 1
- Support esm HOT 7
- "46 times faster" Link in Readme is broken HOT 1
- Some unit tests don't make sense HOT 5
- Performance of this deep equal implementation is generally proportionally between 5x slower and 700x slower compared to native deepStrictEqual HOT 1
- Sets and Maps are not compared properly
- Upgrading to 2.0.1 results in 'return' outside of function error HOT 12
- deep-equal 2.0.1 throws is-weakmap compiler error, 'return' outside of function (12:1) HOT 5
- eslint failing on transitive deep-equal HOT 1
- Fails silently on symbols. HOT 7
- New exports field in package.json get wrong mapping HOT 1
- Dependency Dashboard
- Support for comparing arrays by members without order (set equality) HOT 3
- Incorrect result for ArrayBuffer values HOT 2
- Equivalent objects with NaN values are treated as not equal HOT 3
- Bloat HOT 2
- TO DELETE HOT 1
- `util` `isDeepStrictEqual` is a built-in Node.js function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-deep-equal.