-
Notifications
You must be signed in to change notification settings - Fork 11
/
pipe_test.go
108 lines (92 loc) · 3.49 KB
/
pipe_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package fp
import "testing"
func TestPipe2_Example(t *testing.T) {
res := Pipe2(add1, double)(0)
if res != 2 {
t.Error("Should perform left-to-right function composition of 2 functions. Received:", res)
}
}
func TestPipe3_Example(t *testing.T) {
res := Pipe3(add1, double, add1)(0)
if res != 3 {
t.Error("Should perform left-to-right function composition of 3 functions. Received:", res)
}
}
func TestPipe4_Example(t *testing.T) {
res := Pipe4(add1, double, add1, double)(0)
if res != 6 {
t.Error("Should perform left-to-right function composition of 4 functions. Received:", res)
}
}
func TestPipe5_Example(t *testing.T) {
res := Pipe5(add1, double, add1, double, add1)(0)
if res != 7 {
t.Error("Should perform left-to-right function composition of 5 functions. Received:", res)
}
}
func TestPipe6_Example(t *testing.T) {
res := Pipe6(add1, double, add1, double, add1, double)(0)
if res != 14 {
t.Error("Should perform left-to-right function composition of 6 functions. Received:", res)
}
}
func TestPipe7_Example(t *testing.T) {
res := Pipe7(add1, double, add1, double, add1, double, add1)(0)
if res != 15 {
t.Error("Should perform left-to-right function composition of 7 functions. Received:", res)
}
}
func TestPipe8_Example(t *testing.T) {
res := Pipe8(add1, double, add1, double, add1, double, add1, double)(0)
if res != 30 {
t.Error("Should perform left-to-right function composition of 8 functions. Received:", res)
}
}
func TestPipe9_Example(t *testing.T) {
res := Pipe9(add1, double, add1, double, add1, double, add1, double, add1)(0)
if res != 31 {
t.Error("Should perform left-to-right function composition of 9 functions. Received:", res)
}
}
func TestPipe10_Example(t *testing.T) {
res := Pipe10(add1, double, add1, double, add1, double, add1, double, add1, double)(0)
if res != 62 {
t.Error("Should perform left-to-right function composition of 10 functions. Received:", res)
}
}
func TestPipe11_Example(t *testing.T) {
res := Pipe11(add1, double, add1, double, add1, double, add1, double, add1, double, add1)(0)
if res != 63 {
t.Error("Should perform left-to-right function composition of 11 functions. Received:", res)
}
}
func TestPipe12_Example(t *testing.T) {
res := Pipe12(add1, double, add1, double, add1, double, add1, double, add1, double, add1, double)(0)
if res != 126 {
t.Error("Should perform left-to-right function composition of 12 functions. Received:", res)
}
}
func TestPipe13_Example(t *testing.T) {
res := Pipe13(add1, double, add1, double, add1, double, add1, double, add1, double, add1, double, add1)(0)
if res != 127 {
t.Error("Should perform left-to-right function composition of 13 functions. Received:", res)
}
}
func TestPipe14_Example(t *testing.T) {
res := Pipe14(add1, double, add1, double, add1, double, add1, double, add1, double, add1, double, add1, double)(0)
if res != 254 {
t.Error("Should perform left-to-right function composition of 14 functions. Received:", res)
}
}
func TestPipe15_Example(t *testing.T) {
res := Pipe15(add1, double, add1, double, add1, double, add1, double, add1, double, add1, double, add1, double, add1)(0)
if res != 255 {
t.Error("Should perform left-to-right function composition of 15 functions. Received:", res)
}
}
func TestPipe16_Example(t *testing.T) {
res := Pipe16(add1, double, add1, double, add1, double, add1, double, add1, double, add1, double, add1, double, add1, double)(0)
if res != 510 {
t.Error("Should perform left-to-right function composition of 16 functions. Received:", res)
}
}