hapijs / code

Assertion library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong assertion for `-0`

Gopikrishna19 opened this issue · comments

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

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

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

@cjihrig Thanks and done :)

commented

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.