Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
fixed equivalence
Browse files Browse the repository at this point in the history
  • Loading branch information
jessekelly881 committed Nov 23, 2023
1 parent 791d8e0 commit 1c584dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3555,7 +3555,7 @@ export const BigDecimalFromSelf: Schema<BigDecimal.BigDecimal> = declare(
[AST.IdentifierAnnotationId]: "BigDecimal",
[Internal.PrettyHookId]: bigDecimalPretty,
[Internal.ArbitraryHookId]: bigDecimalArbitrary,
[Internal.EquivalenceHookId]: BigDecimal.Equivalence
[Internal.EquivalenceHookId]: () => BigDecimal.Equivalence
}
)

Expand Down
10 changes: 10 additions & 0 deletions test/BigDecimal/BigDecimalFromSelf.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Equivalence from "@effect/schema/Equivalence"
import * as Pretty from "@effect/schema/Pretty"
import * as S from "@effect/schema/Schema"
import * as Util from "@effect/schema/test/util"
Expand Down Expand Up @@ -39,4 +40,13 @@ describe("Schema/DurationFromSelf", () => {
expect(pretty(BigDecimal.unsafeFromString("123.100"))).toEqual("BigDecimal(123.1)")
expect(pretty(BigDecimal.unsafeFromString(""))).toEqual("BigDecimal(0)")
})

it("equivalence", () => {
const schema = S.BigDecimalFromSelf
const equivalence = Equivalence.to(schema)

expect(equivalence(BigDecimal.fromNumber(1), BigDecimal.unsafeFromString("1"))).to.be.true
expect(equivalence(BigDecimal.fromNumber(2), BigDecimal.unsafeFromString("1"))).to.be.false
expect(equivalence(BigDecimal.fromNumber(1), BigDecimal.unsafeFromString("2"))).to.be.false
})
})

0 comments on commit 1c584dd

Please sign in to comment.