X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=test%2Fhope_fun_SUITE.erl;h=333c81f74c5184cb44f66a613465aca1805a0f44;hb=HEAD;hp=d4e2281aa446edd229bf7ab8d8daaf11af777182;hpb=64617423d513e37494369d637bee5ff357de791b;p=hope.git diff --git a/test/hope_fun_SUITE.erl b/test/hope_fun_SUITE.erl index d4e2281..333c81f 100644 --- a/test/hope_fun_SUITE.erl +++ b/test/hope_fun_SUITE.erl @@ -8,7 +8,10 @@ %% Test cases -export( - [ t_id/1 + [ t_specs/1 + , t_id/1 + , t_curry/1 + , t_compose_and_thread/1 ]). @@ -25,7 +28,10 @@ all() -> groups() -> Tests = - [ t_id + [ t_specs + , t_id + , t_curry + , t_compose_and_thread ], Properties = [parallel], [ {?GROUP, Properties, Tests} @@ -36,6 +42,36 @@ groups() -> %% Test cases %% ============================================================================= +t_specs(_) -> + [] = proper:check_specs(hope_fun). + t_id(_Cfg) -> X = foo, X = hope_fun:id(X). + +t_curry(_Cfg) -> + Single = fun (X) -> X end, + Double = fun (X, Y) -> {X, Y} end, + Triple = fun (X, Y, Z) -> {X, Y, Z} end, + + F = hope_fun:curry(Single), + a = F(a), + + G1 = hope_fun:curry(Double), + G = G1(a), + {a, b} = G(b), + + H1 = hope_fun:curry(Triple), + H2 = H1(a), + H = H2(b), + {a, b, c} = H(c). + +t_compose_and_thread(_Cfg) -> + A2B = fun (a) -> b end, + B2C = fun (b) -> c end, + C2D = fun (c) -> d end, + Fs = [C2D, B2C, A2B], + d = (hope_fun:compose ( Fs ))(a), + d = (hope_fun:compose_right ( Fs ))(a), + d = (hope_fun:compose_left (lists:reverse(Fs) ))(a), + d = hope_fun:thread (lists:reverse(Fs), a).