Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bumpy-pears-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-atom/atom": patch
---

fix Result to consider waiting flag in equality
2 changes: 1 addition & 1 deletion packages/atom/src/Result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const ResultProto = {
return pipeArguments(this, arguments)
},
[Equal.symbol](this: Result<any, any>, that: Result<any, any>): boolean {
if (this._tag !== that._tag && this.waiting !== that.waiting) {
if (this._tag !== that._tag || this.waiting !== that.waiting) {
return false
}
switch (this._tag) {
Expand Down
12 changes: 11 additions & 1 deletion packages/atom/test/Result.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as _ from "@effect-atom/atom/Result"
import { Cause } from "effect"
import { Cause, Equal } from "effect"
import { describe, expect, it } from "vitest"

describe("Result", () => {
Expand All @@ -14,4 +14,14 @@ describe("Result", () => {
expect(matcher(_.failure(Cause.empty))).toEqual("fail")
expect(matcher(_.success(1))).toEqual(1)
})

it("considers waiting flag in equality", () => {
const success = _.success("value")
const waiting = _.waiting(success)

expect(Equal.isEqual(success)).toBe(true)
expect(Equal.isEqual(waiting)).toBe(true)
expect(Equal.equals(success, waiting)).toBe(false)
expect((success as any)[Equal.symbol](waiting)).toBe(false)
})
})