-
Notifications
You must be signed in to change notification settings - Fork 630
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
assertStrictEquals(-0, +0) should not throw #4714
Comments
Fix `assertStrictEquals` to consider -0 and +0 to be equal. Follow the [MDN recommendation] by replacing `Object.is` with `===` and handling NaNs specifically. [MDN recommendation]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#when_to_use_object.is_versus_triple_equals
fix(assert): let assertStrictEquals(-0, +0) pass (#4714) Fix `assertStrictEquals` to consider -0 and +0 to be equal. Follow the [MDN recommendation] by replacing `Object.is` with `===` and handling NaNs specifically. [MDN recommendation]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#when_to_use_object.is_versus_triple_equals
Note: In Node.js, +0 and -0 are not equal with |
That's a fair point. Should we adhere to ECMA's definition of strict equality ( |
Jest and Vitest also follow what Node.js does. The below examples throw in jest and vitest: Jest expect(+0).toStrictEqual(-0); Vitest import { expect, test } from 'vitest'
expect(+0).toStrictEqual(-0); |
Ok. I'll revert and instead add a note explaining the behavior. |
Describe the Bug
According to the Strict Equality Comparison Algorithm of the Javascript standard, -0 and +0 are considered equal.
Assuming that
assertStrictEquals
is meant to assert equality in the sense ofactual === expected
, it should not throw when passing -0 and +0 foractual
andexpected
.Steps to Reproduce
Expected Behavior
assertStrictEquals(-0, +0)
should not throw.Environment
The text was updated successfully, but these errors were encountered: