X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=test%2Fhope_result_SUITE.erl;h=390f28c076b001efb1de982e83587e30285440cb;hb=b79afea06befb5309f4a3f0388e587e17c484b83;hp=4f16b64c54841344bcdff348e754269787d0d0d2;hpb=8bbf6f4d400d79736e7866d67ecb3517b61bb1c1;p=hope.git diff --git a/test/hope_result_SUITE.erl b/test/hope_result_SUITE.erl index 4f16b64..390f28c 100644 --- a/test/hope_result_SUITE.erl +++ b/test/hope_result_SUITE.erl @@ -1,5 +1,6 @@ -module(hope_result_SUITE). +%% TODO: Import only what is used. -include_lib("proper/include/proper.hrl"). %% Callbacks @@ -15,10 +16,13 @@ [ t_pipe_ok/1 , t_pipe_error/1 , t_hope_result_specs/1 + , t_lift_exn/1 ]). -define(GROUP_PIPE, result_pipe). +-define(GROUP_SPEC, result_spec). +-define(GROUP_LIFT, result_lift_exn). %% ============================================================================ @@ -26,17 +30,32 @@ %% ============================================================================ all() -> - [{group, ?GROUP_PIPE}]. + [ {group, ?GROUP_PIPE} + , {group, ?GROUP_SPEC} + , {group, ?GROUP_LIFT} + ]. groups() -> - Tests = + PipeTests = [ t_pipe_ok , t_pipe_error - , t_hope_result_specs + ], + SpecTests = + [ t_hope_result_specs + ], + LiftTests = + [ t_lift_exn ], Properties = [parallel], - [{?GROUP_PIPE, Properties, Tests}]. - + [ {?GROUP_PIPE, Properties, PipeTests} + , {?GROUP_SPEC, Properties, SpecTests} + , {?GROUP_LIFT, Properties, LiftTests} + ]. + +init_per_group(?GROUP_LIFT, Cfg) -> + Cfg; +init_per_group(?GROUP_SPEC, Cfg) -> + Cfg; init_per_group(?GROUP_PIPE, Cfg) -> Steps = [ fun (0) -> {ok, 1}; (X) -> {error, X} end @@ -45,6 +64,10 @@ init_per_group(?GROUP_PIPE, Cfg) -> ], hope_kv_list:set(Cfg, steps, Steps). +end_per_group(?GROUP_LIFT, _Cfg) -> + ok; +end_per_group(?GROUP_SPEC, _Cfg) -> + ok; end_per_group(?GROUP_PIPE, _Cfg) -> ok. @@ -63,3 +86,13 @@ t_pipe_error(Cfg) -> t_hope_result_specs(_) -> [] = proper:check_specs(hope_result). + +t_lift_exn(_Cfg) -> + Class = throw, + Reason = foofoo, + Label = bar, + F = fun (ok) -> apply(erlang, Class, [Reason]) end, + G = hope_result:lift_exn(F), + H = hope_result:lift_exn(F, Label), + {error, {Class, Reason}} = G(ok), + {error, {Label, {Class, Reason}}} = H(ok).