1 -module(hope_option_SUITE).
21 -define(GROUP, option).
24 %% ============================================================================
25 %% Common Test callbacks
26 %% ============================================================================
42 Properties = [parallel],
43 [ {?GROUP, Properties, Tests}
47 %% =============================================================================
49 %% =============================================================================
52 IsFoo = fun (foo) -> true; (_) -> false end,
53 {some, foo} = hope_option:put(foo, IsFoo),
54 none = hope_option:put(bar, IsFoo).
57 foo = hope_option:get({some, foo}, bar),
58 bar = hope_option:get(none , bar).
61 FooToBar = fun (foo) -> bar end,
62 {some, bar} = hope_option:map({some, foo}, FooToBar),
63 none = hope_option:map(none , FooToBar).
67 Put = fun (Val) -> _ = put(Key, Val), ok end,
68 Get = fun () -> get(Key) end,
70 ok = hope_option:iter(none , Put),
72 ok = hope_option:iter({some, Val}, Put),
79 ResultError = {error, Bar},
80 {some, Foo} = hope_option:of_result(ResultOk),
81 none = hope_option:of_result(ResultError).
85 [ fun (0) -> hope_option:return(1); (_) -> none end
86 , fun (1) -> hope_option:return(2); (_) -> none end
87 , fun (2) -> hope_option:return(3); (_) -> none end
89 {some, 3} = hope_option:pipe(Steps, 0),
90 none = hope_option:pipe(Steps, 1),
91 none = hope_option:pipe(Steps, 2),
92 none = hope_option:pipe(Steps, 3).
94 t_of_undefined(_Cfg) ->
98 {some, Foo} = hope_option:of_undefined(Foo),
99 {some, Bar} = hope_option:of_undefined(Bar),
100 {some, Baz} = hope_option:of_undefined(Baz),
101 none = hope_option:of_undefined(undefined).