-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTuple.spec.ts
26 lines (22 loc) · 912 Bytes
/
Tuple.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/** Typeclass law tests for the tuple datatype. */
import {Bicovariant} from '@effect/typeclass/data/Tuple'
import {Equivalence as EQ, pipe, String as STR, Tuple as TU} from 'effect'
import {monoEquivalence, monoOrder} from 'effect-ts-laws'
import {testTypeclassLaws} from 'effect-ts-laws/vitest'
import {TupleTypeLambda} from 'effect/Tuple'
import fc from 'fast-check'
describe('@effect/typeclass/data/Tuple', () => {
const getEquivalence = <A>(
a: EQ.Equivalence<A>,
): EQ.Equivalence<[string, A]> => TU.getEquivalence(STR.Equivalence, a)
const getArbitrary = <A>(a: fc.Arbitrary<A>): fc.Arbitrary<[string, A]> =>
fc.tuple(fc.string({maxLength: 5}), a)
const [Equivalence, Order] = [
getEquivalence(monoEquivalence),
TU.getOrder(STR.Order, monoOrder),
]
pipe(
{Bicovariant, Equivalence, Order},
testTypeclassLaws<TupleTypeLambda>({getEquivalence, getArbitrary}),
)
})