1 -module(hope_list_SUITE).
3 -include_lib("proper/include/proper.hrl").
13 [ t_unique_preserve_order/1
23 -define(GROUP , hope_list).
25 -define(PROPTEST(A), true = proper:quickcheck(A())).
28 %% ============================================================================
29 %% Common Test callbacks
30 %% ============================================================================
37 [ t_unique_preserve_order
45 Properties = [parallel],
46 [{?GROUP, Properties, Tests}].
49 %% =============================================================================
51 %% =============================================================================
57 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
58 hope_list:map_rev(L, F) == lists:reverse(lists:map(F, L))).
64 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
65 hope_list:map_slow(L, F) == lists:map(F, L)).
71 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
72 hope_list:map(L, F) == lists:map(F, L)).
78 ?FORALL({L, F, N}, {list(integer()), function([integer()], term()), non_neg_integer()},
79 hope_list:map(L, F, N) == lists:map(F, L)).
81 t_unique_preserve_order(_Cfg) ->
82 ?PROPTEST(prop_unique_preserve_order).
84 prop_unique_preserve_order() ->
87 Duplicates = L -- lists:usort(L),
88 hope_list:unique_preserve_order(L) ==
89 lists:reverse(lists:reverse(L) -- Duplicates)
92 t_hope_list_specs(_) ->
93 [] = proper:check_specs(hope_list).
97 fun (I) when I > 0 -> {ok, I}; (_) -> {error, negative} end,
98 AllPositives = lists:seq(1, 5),
99 AllNegatives = lists:seq(-5, -1),
100 Mixed = lists:seq(-5, 5),
101 {ok, AllPositives} = hope_list:map_result(AllPositives, AssertPositive),
102 {error, negative} = hope_list:map_result(AllNegatives, AssertPositive),
103 {error, negative} = hope_list:map_result(Mixed, AssertPositive).