feat: add Compose in function.go

This commit is contained in:
dudaodong
2021-12-13 20:15:34 +08:00
parent 72a89be8c1
commit d1b74cfcfb
2 changed files with 38 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package function
import (
"fmt"
"reflect"
"strings"
"testing"
"time"
)
@@ -69,6 +70,26 @@ func TestCurry(t *testing.T) {
}
}
func TestCompose(t *testing.T) {
toUpper := func(a... string) string {
return strings.ToUpper(a[0])
}
toLower := func(a... string) string {
return strings.ToLower(a[0])
}
expect := toUpper(toLower("aBCde"))
cf := Compose(toUpper, toLower)
res := cf("aBCde")
fmt.Println(res, expect)
if res != expect {
t.FailNow()
}
}
func TestDelay(t *testing.T) {
var print = func(s string) {
fmt.Println(s)