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(CHECK(F), true = proper:quickcheck(F())).
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 %% =============================================================================
56 ?CHECK(proper_spec_map_rev).
59 ?CHECK(proper_spec_map_slow).
62 ?CHECK(proper_spec_map).
65 ?CHECK(proper_spec_map_3).
67 t_unique_preserve_order(_Cfg) ->
68 ?CHECK(proper_spec_prop_unique_preserve_order).
70 t_hope_list_specs(_Cfg) ->
71 [] = proper:check_specs(hope_list).
75 fun (I) when I > 0 -> {ok, I}; (_) -> {error, negative} end,
76 AllPositives = lists:seq(1, 5),
77 AllNegatives = lists:seq(-5, -1),
78 Mixed = lists:seq(-5, 5),
79 {ok, AllPositives} = hope_list:map_result(AllPositives, AssertPositive),
80 {error, negative} = hope_list:map_result(AllNegatives, AssertPositive),
81 {error, negative} = hope_list:map_result(Mixed, AssertPositive).
83 %% ============================================================================
85 %% ============================================================================
87 proper_spec_map_rev() ->
88 ?FORALL({L, F}, {type_l(), type_f()},
89 hope_list:map_rev(L, F) == lists:reverse(lists:map(F, L))
92 proper_spec_map_slow() ->
93 ?FORALL({L, F}, {type_l(), type_f()},
94 hope_list:map_slow(L, F) == lists:map(F, L)
98 ?FORALL({L, F}, {type_l(), type_f()},
99 hope_list:map(L, F) == lists:map(F, L)
102 proper_spec_map_3() ->
103 ?FORALL({L, F, N}, {type_l(), type_f(), ?type:non_neg_integer()},
104 hope_list:map(L, F, N) == lists:map(F, L)
107 proper_spec_prop_unique_preserve_order() ->
108 ?FORALL(L, ?type:list(),
110 Duplicates = L -- lists:usort(L),
111 hope_list:unique_preserve_order(L) ==
112 lists:reverse(lists:reverse(L) -- Duplicates)
116 ?type:list(?type:integer()).
119 ?type:function([?type:integer()], ?type:term()).