-t_pipe(_Config) ->
- A = foo,
- Z = qux,
- Steps =
- [ fun (foo) -> {ok, bar}; (X) -> {error, X} end
- , fun (bar) -> {ok, baz}; (X) -> {error, X} end
- , fun (baz) -> {ok, qux}; (X) -> {error, X} end
- ],
- {ok, Z} = hope_result:pipe(Steps, A).
+t_pipe_ok(Cfg) ->
+ {some, Steps} = hope_kv_list:get(Cfg, steps),
+ {ok, 3} = hope_result:pipe(Steps, 0).
+
+t_pipe_error(Cfg) ->
+ {some, Steps} = hope_kv_list:get(Cfg, steps),
+ {error, 1} = hope_result:pipe(Steps, 1).
+
+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).
+
+t_return(_Cfg) ->
+ X = foo,
+ {ok, X} = hope_result:return(X).
+
+t_map(_Cfg) ->
+ X = foo,
+ Y = bar,
+ F = fun (foo) -> Y end,
+ {ok, Y} = hope_result:map({ok, X}, F),
+ {error, X} = hope_result:map({error, X}, F).