Skip to content

Commit 5fb124e

Browse files
fix null/non-null equality, bad bug
fixes #74
1 parent 7d1f788 commit 5fb124e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Comparison.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function stringHashCode(str: string): number {
8282
* if possible, degrades to === if not available, and is also null-safe.
8383
*/
8484
export function areEqual(obj: any|null, obj2: any|null): boolean {
85-
if (obj === null != obj2 === null) {
85+
if ((obj === null) != (obj2 === null)) {
8686
return false;
8787
}
8888
if (obj === null || obj2 === null) {

tests/Option.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ describe("option comparison", () => {
1717
assert.ok(Option.of(5).equals(Option.of(5))))
1818
it("should mark different options as not equal", () =>
1919
assert.ok(!Option.of(5).equals(Option.of(6))))
20+
it("should mark different options as not equal", () =>
21+
assert.ok(!Option.of<any>(Vector.of(12, 2674)).equals(Option.of<any>(null))))
2022
it("should mark none as equals to none", () =>
2123
assert.ok(Option.none<string>().equals(Option.none<string>())));
2224
it("should mark none and some as not equal", () =>

0 commit comments

Comments
 (0)