Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added isEq to _.isEqual for proper equality checking of 0 and -0 in sets and maps #2508

Closed
wants to merge 4 commits into from

Conversation

aebrow4
Copy link

@aebrow4 aebrow4 commented Apr 21, 2016

This address #2456 and #2507.
I cancelled my last pull request and moved isEq to be an internal function that is included inside of _.isEqual. It will call deepEq to compare object values, which will continue to call eq unless it encounter a set or a map, in which case it will call isEq for proper handling of 0 and -0.

andrew brown added 2 commits April 20, 2016 13:55
_.isEq(a, b) performs a SameValueZero comparison on values a and b.
http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero
…nd maps.

Implemented an internal isEq function that is called by deepEq when testing equality of key values for maps or sets.  0 and -0 should be considered equal for set and keys of maps (but not values) which is why this change was needed.
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.4%) to 95.443% when pulling 2e53862 on aebrow4:master into cb95672 on jashkenas:master.

…gs with test case purpose to a couple of tests that were missing them.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.6%) to 96.305% when pulling c05eefe on aebrow4:master into cb95672 on jashkenas:master.

@aebrow4
Copy link
Author

aebrow4 commented Apr 21, 2016

Node did not recognize the Set constructor in the test script.
underscore/test/objects.js:569:23

PhantomJS 2.1.1 (Linux 0.0.0) Objects isEqual FAILED
Died on test #100 /home/travis/build/jashkenas/underscore/test/objects.js:315:13
global code@/home/travis/build/jashkenas/underscore/test/objects.js:1110:2: Can't find variable: Set
/home/travis/build/jashkenas/underscore/test/objects.js:569:23

@aebrow4
Copy link
Author

aebrow4 commented Apr 26, 2016

@jdalton is any action on my part required? Since the build check that failed seems to be related to Node not recognizing the Set constructor I am assuming no.

@michaelficarra
Copy link
Collaborator

@aebrow4 You should guard those tests on the existence of Set

@aebrow4
Copy link
Author

aebrow4 commented May 3, 2016

@michaelficarra I looked at this for a while but couldn't figure out what I need to do, since all of the tests in object.js are passing and the problem seems to be in a file module.js that is not in the repo. If you could give me more information on what to do that would helpful.

image

@michaelficarra
Copy link
Collaborator

@aebrow4 You have to wrap the section of the test that mentions Set in if (typeof Set != "undefined") { ... }. And similarly for Map. See similar tests with Symbol or Promise if you're still confused.

@coveralls
Copy link

coveralls commented May 3, 2016

Coverage Status

Coverage decreased (-0.6%) to 96.305% when pulling f4c9859 on aebrow4:master into cb95672 on jashkenas:master.

@aebrow4
Copy link
Author

aebrow4 commented May 31, 2016

@michaelficarra all taken care of now

@jgonggrijp
Copy link
Collaborator

Closing because this is only a partial implementation of #2147, and because the the eq/deepEq split already exists on master.

@jgonggrijp jgonggrijp closed this Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants