1 -module(hope_list_SUITE).
3 -include_lib("proper/include/proper_common.hrl").
13 [ t_unique_preserve_order/1
23 -define(GROUP , hope_list).
25 -define(PROPTEST(A), true = proper:quickcheck(A())).
27 -define(type, proper_types).
30 %% ============================================================================
31 %% Common Test callbacks
32 %% ============================================================================
39 [ t_unique_preserve_order
47 Properties = [parallel],
48 [{?GROUP, Properties, Tests}].
51 %% =============================================================================
53 %% =============================================================================
59 ?FORALL({L, F}, {?type:list(?type:integer()), ?type:function([?type:integer()], ?type:term())},
60 hope_list:map_rev(L, F) == lists:reverse(lists:map(F, L))).
66 ?FORALL({L, F}, {?type:list(?type:integer()), ?type:function([?type:integer()], ?type:term())},
67 hope_list:map_slow(L, F) == lists:map(F, L)).
73 ?FORALL({L, F}, {?type:list(?type:integer()), ?type:function([?type:integer()], ?type:term())},
74 hope_list:map(L, F) == lists:map(F, L)).
80 ?FORALL({L, F, N}, {?type:list(?type:integer()), ?type:function([?type:integer()], ?type:term()), ?type:non_neg_integer()},
81 hope_list:map(L, F, N) == lists:map(F, L)).
83 t_unique_preserve_order(_Cfg) ->
84 ?PROPTEST(prop_unique_preserve_order).
86 prop_unique_preserve_order() ->
87 ?FORALL(L, ?type:list(),
89 Duplicates = L -- lists:usort(L),
90 hope_list:unique_preserve_order(L) ==
91 lists:reverse(lists:reverse(L) -- Duplicates)
94 t_hope_list_specs(_) ->
95 [] = proper:check_specs(hope_list).
99 fun (I) when I > 0 -> {ok, I}; (_) -> {error, negative} end,
100 AllPositives = lists:seq(1, 5),
101 AllNegatives = lists:seq(-5, -1),
102 Mixed = lists:seq(-5, 5),
103 {ok, AllPositives} = hope_list:map_result(AllPositives, AssertPositive),
104 {error, negative} = hope_list:map_result(AllNegatives, AssertPositive),
105 {error, negative} = hope_list:map_result(Mixed, AssertPositive).