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

Wrong assertion for -0 #96

Closed
Gopikrishna19 opened this issue Nov 25, 2016 · 4 comments
Closed

Wrong assertion for -0 #96

Gopikrishna19 opened this issue Nov 25, 2016 · 4 comments
Assignees
Labels
support Questions, discussions, and general support

Comments

@Gopikrishna19
Copy link

Gopikrishna19 commented Nov 25, 2016

the following code fails:

const a = 0;

expect(-a).equals(0);

while doing a shallow equals passes:

const a = 0;

expect(-a).shallow.equals(0);

Is this an intended feature? shouldn't '-0' be equal to '0', since javascript tells that 0 === -0 is true? Please let me know. Thanks

@Gopikrishna19
Copy link
Author

Gopikrishna19 commented Nov 25, 2016

I also noticed that this feature is not reflected for a +0:

const a = 0;

expect(+a).shallow.equals(0); //passes
expect(+a).equals(0); //passes

@cjihrig
Copy link
Contributor

cjihrig commented Nov 26, 2016

Thanks for reporting this.

Shallow comparison passes because it uses a strict JavaScript comparison. Deep equal outsources the comparison to Hoek. It looks like this issue probably comes from this line. Please open this issue there.

cc: @nlf

@Gopikrishna19
Copy link
Author

@cjihrig Thanks and done :)

@Marsup Marsup added the support Questions, discussions, and general support label Sep 20, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

3 participants