Skip to content

Commit

Permalink
Allow is_equal(0, -0) to be true to match === (bokeh#14038)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpap authored Aug 23, 2024
1 parent 496611f commit d0f895a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bokehjs/src/lib/core/util/eq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Comparator {
}

eq(a: any, b: any): boolean {
if (Object.is(a, b)) {
if (a === b || Object.is(a, b)) {
return true
}

Expand Down Expand Up @@ -127,7 +127,7 @@ export class Comparator {
}

numbers(a: number, b: number): boolean {
return Object.is(a, b)
return a === b || Object.is(a, b)
}

arrays(a: ArrayLike<unknown>, b: ArrayLike<unknown>): boolean {
Expand Down
4 changes: 2 additions & 2 deletions bokehjs/test/unit/core/util/eq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ describe("core/util/eq module", () => {
describe("implements is_equal() function", () => {
it("that supports number type", () => {
expect(is_equal(0, 0)).to.be.true
expect(is_equal(0, -0)).to.be.false
expect(is_equal(-0, 0)).to.be.false
expect(is_equal(0, -0)).to.be.true
expect(is_equal(-0, 0)).to.be.true
expect(is_equal(-0, -0)).to.be.true
expect(is_equal(0, 1)).to.be.false
expect(is_equal(1, 0)).to.be.false
Expand Down

0 comments on commit d0f895a

Please sign in to comment.