forked from SimonRichardson/wishful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
io_test.go
80 lines (66 loc) · 1.78 KB
/
io_test.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package wishful
import (
"testing"
"testing/quick"
)
func extractIO(x Any) Any {
io := x.(IO)
return io.UnsafePerform()
}
// Applicative Laws
func Test_IO_ApplicativeLaws_Identity(t *testing.T) {
f, g := NewApplicativeLaws(IO{}).Identity(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
func Test_IO_ApplicativeLaws_Composition(t *testing.T) {
f, g := NewApplicativeLaws(IO{}).Composition(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
func Test_IO_ApplicativeLaws_Homomorphism(t *testing.T) {
f, g := NewApplicativeLaws(IO{}).Homomorphism(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
func Test_IO_ApplicativeLaws_Interchange(t *testing.T) {
f, g := NewApplicativeLaws(IO{}).Interchange(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
// Functor Laws
func Test_IO_FunctorLaws_Identity(t *testing.T) {
f, g := NewFunctorLaws(IO{}).Identity(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
func Test_IO_FunctorLaws_Composition(t *testing.T) {
f, g := NewFunctorLaws(IO{}).Composition(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
// Monad Laws
func Test_IO_MonadLaws_LeftIdentity(t *testing.T) {
f, g := NewMonadLaws(IO{}).LeftIdentity(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
func Test_IO_MonadLaws_RightIdentity(t *testing.T) {
f, g := NewMonadLaws(IO{}).RightIdentity(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}
func Test_IO_MonadLaws_Associativity(t *testing.T) {
f, g := NewMonadLaws(IO{}).Associativity(extractIO)
if err := quick.CheckEqual(f, g, nil); err != nil {
t.Error(err)
}
}