1 -module(hope_option_SUITE).
20 -define(GROUP, option).
23 %% ============================================================================
24 %% Common Test callbacks
25 %% ============================================================================
40 Properties = [parallel],
41 [ {?GROUP, Properties, Tests}
45 %% =============================================================================
47 %% =============================================================================
50 IsFoo = fun (foo) -> true; (_) -> false end,
51 {some, foo} = hope_option:put(foo, IsFoo),
52 none = hope_option:put(bar, IsFoo).
55 foo = hope_option:get({some, foo}, bar),
56 bar = hope_option:get(none , bar).
59 FooToBar = fun (foo) -> bar end,
60 {some, bar} = hope_option:map({some, foo}, FooToBar),
61 none = hope_option:map(none , FooToBar).
65 Put = fun (Val) -> _ = put(Key, Val), ok end,
66 Get = fun () -> get(Key) end,
68 ok = hope_option:iter(none , Put),
70 ok = hope_option:iter({some, Val}, Put),
77 ResultError = {error, Bar},
78 {some, Foo} = hope_option:of_result(ResultOk),
79 none = hope_option:of_result(ResultError).
83 [ fun (0) -> hope_option:return(1); (_) -> none end
84 , fun (1) -> hope_option:return(2); (_) -> none end
85 , fun (2) -> hope_option:return(3); (_) -> none end
87 {some, 3} = hope_option:pipe(Steps, 0),
88 none = hope_option:pipe(Steps, 1),
89 none = hope_option:pipe(Steps, 2),
90 none = hope_option:pipe(Steps, 3).