@@ -3,114 +3,114 @@ package fp
3
3
import "testing"
4
4
5
5
func add1 (x int ) int {
6
- return x + 1
6
+ return x + 1
7
7
}
8
8
9
9
func double (x int ) int {
10
- return x * 2
10
+ return x * 2
11
11
}
12
12
13
13
func TestCompose2_Example (t * testing.T ) {
14
- res := Compose2 (add1 , double )(0 )
15
- if res != 1 {
16
- t .Error ("Should perform right-to-left function composition of 2 functions. Received:" , res )
17
- }
14
+ res := Compose2 (add1 , double )(0 )
15
+ if res != 1 {
16
+ t .Error ("Should perform right-to-left function composition of 2 functions. Received:" , res )
17
+ }
18
18
}
19
19
20
20
func TestCompose3_Example (t * testing.T ) {
21
- res := Compose3 (add1 , double , add1 )(0 )
22
- if res != 3 {
23
- t .Error ("Should perform right-to-left function composition of 3 functions. Received:" , res )
24
- }
21
+ res := Compose3 (add1 , double , add1 )(0 )
22
+ if res != 3 {
23
+ t .Error ("Should perform right-to-left function composition of 3 functions. Received:" , res )
24
+ }
25
25
}
26
26
27
27
func TestCompose4_Example (t * testing.T ) {
28
- res := Compose4 (add1 , double , add1 , double )(0 )
29
- if res != 3 {
30
- t .Error ("Should perform right-to-left function composition of 4 functions. Received:" , res )
31
- }
28
+ res := Compose4 (add1 , double , add1 , double )(0 )
29
+ if res != 3 {
30
+ t .Error ("Should perform right-to-left function composition of 4 functions. Received:" , res )
31
+ }
32
32
}
33
33
34
34
func TestCompose5_Example (t * testing.T ) {
35
- res := Compose5 (add1 , double , add1 , double , add1 )(0 )
36
- if res != 7 {
37
- t .Error ("Should perform right-to-left function composition of 5 functions. Received:" , res )
38
- }
35
+ res := Compose5 (add1 , double , add1 , double , add1 )(0 )
36
+ if res != 7 {
37
+ t .Error ("Should perform right-to-left function composition of 5 functions. Received:" , res )
38
+ }
39
39
}
40
40
41
41
func TestCompose6_Example (t * testing.T ) {
42
- res := Compose6 (add1 , double , add1 , double , add1 , double )(0 )
43
- if res != 7 {
44
- t .Error ("Should perform right-to-left function composition of 6 functions. Received:" , res )
45
- }
42
+ res := Compose6 (add1 , double , add1 , double , add1 , double )(0 )
43
+ if res != 7 {
44
+ t .Error ("Should perform right-to-left function composition of 6 functions. Received:" , res )
45
+ }
46
46
}
47
47
48
48
func TestCompose7_Example (t * testing.T ) {
49
- res := Compose7 (add1 , double , add1 , double , add1 , double , add1 )(0 )
50
- if res != 15 {
51
- t .Error ("Should perform right-to-left function composition of 7 functions. Received:" , res )
52
- }
49
+ res := Compose7 (add1 , double , add1 , double , add1 , double , add1 )(0 )
50
+ if res != 15 {
51
+ t .Error ("Should perform right-to-left function composition of 7 functions. Received:" , res )
52
+ }
53
53
}
54
54
55
55
func TestCompose8_Example (t * testing.T ) {
56
- res := Compose8 (add1 , double , add1 , double , add1 , double , add1 , double )(0 )
57
- if res != 15 {
58
- t .Error ("Should perform right-to-left function composition of 8 functions. Received:" , res )
59
- }
56
+ res := Compose8 (add1 , double , add1 , double , add1 , double , add1 , double )(0 )
57
+ if res != 15 {
58
+ t .Error ("Should perform right-to-left function composition of 8 functions. Received:" , res )
59
+ }
60
60
}
61
61
62
62
func TestCompose9_Example (t * testing.T ) {
63
- res := Compose9 (add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
64
- if res != 31 {
65
- t .Error ("Should perform right-to-left function composition of 9 functions. Received:" , res )
66
- }
63
+ res := Compose9 (add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
64
+ if res != 31 {
65
+ t .Error ("Should perform right-to-left function composition of 9 functions. Received:" , res )
66
+ }
67
67
}
68
68
69
69
func TestCompose10_Example (t * testing.T ) {
70
- res := Compose10 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
71
- if res != 31 {
72
- t .Error ("Should perform right-to-left function composition of 10 functions. Received:" , res )
73
- }
70
+ res := Compose10 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
71
+ if res != 31 {
72
+ t .Error ("Should perform right-to-left function composition of 10 functions. Received:" , res )
73
+ }
74
74
}
75
75
76
76
func TestCompose11_Example (t * testing.T ) {
77
- res := Compose11 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
78
- if res != 63 {
79
- t .Error ("Should perform right-to-left function composition of 11 functions. Received:" , res )
80
- }
77
+ res := Compose11 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
78
+ if res != 63 {
79
+ t .Error ("Should perform right-to-left function composition of 11 functions. Received:" , res )
80
+ }
81
81
}
82
82
83
83
func TestCompose12_Example (t * testing.T ) {
84
- res := Compose12 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
85
- if res != 63 {
86
- t .Error ("Should perform right-to-left function composition of 12 functions. Received:" , res )
87
- }
84
+ res := Compose12 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
85
+ if res != 63 {
86
+ t .Error ("Should perform right-to-left function composition of 12 functions. Received:" , res )
87
+ }
88
88
}
89
89
90
90
func TestCompose13_Example (t * testing.T ) {
91
- res := Compose13 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
92
- if res != 127 {
93
- t .Error ("Should perform right-to-left function composition of 13 functions. Received:" , res )
94
- }
91
+ res := Compose13 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
92
+ if res != 127 {
93
+ t .Error ("Should perform right-to-left function composition of 13 functions. Received:" , res )
94
+ }
95
95
}
96
96
97
97
func TestCompose14_Example (t * testing.T ) {
98
- res := Compose14 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
99
- if res != 127 {
100
- t .Error ("Should perform right-to-left function composition of 14 functions. Received:" , res )
101
- }
98
+ res := Compose14 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
99
+ if res != 127 {
100
+ t .Error ("Should perform right-to-left function composition of 14 functions. Received:" , res )
101
+ }
102
102
}
103
103
104
104
func TestCompose15_Example (t * testing.T ) {
105
- res := Compose15 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
106
- if res != 255 {
107
- t .Error ("Should perform right-to-left function composition of 15 functions. Received:" , res )
108
- }
105
+ res := Compose15 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 )(0 )
106
+ if res != 255 {
107
+ t .Error ("Should perform right-to-left function composition of 15 functions. Received:" , res )
108
+ }
109
109
}
110
110
111
111
func TestCompose16_Example (t * testing.T ) {
112
- res := Compose16 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
113
- if res != 255 {
114
- t .Error ("Should perform right-to-left function composition of 16 functions. Received:" , res )
115
- }
116
- }
112
+ res := Compose16 (add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double , add1 , double )(0 )
113
+ if res != 255 {
114
+ t .Error ("Should perform right-to-left function composition of 16 functions. Received:" , res )
115
+ }
116
+ }
0 commit comments