1 -module(hope_list_SUITE).
3 -include_lib("proper/include/proper_common.hrl").
13 [ t_auto_hope_list_specs/1
18 , t_auto_unique_preserve_order/1
19 , t_manual_map_result/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_auto_hope_list_specs
44 , t_auto_unique_preserve_order
47 Properties = [parallel],
48 [{?GROUP, Properties, Tests}].
50 %% =============================================================================
52 %% =============================================================================
54 t_manual_map_result(_Cfg) ->
56 fun (I) when I > 0 -> {ok, I}; (_) -> {error, negative} end,
57 AllPositives = lists:seq(1, 5),
58 AllNegatives = lists:seq(-5, -1),
59 Mixed = lists:seq(-5, 5),
60 {ok, AllPositives} = hope_list:map_result(AllPositives, AssertPositive),
61 {error, negative} = hope_list:map_result(AllNegatives, AssertPositive),
62 {error, negative} = hope_list:map_result(Mixed, AssertPositive).
64 %% =============================================================================
65 %% Generated test cases
66 %% =============================================================================
68 t_auto_map_rev(_Cfg) ->
69 ?CHECK(proper_spec_map_rev).
71 t_auto_map_slow(_Cfg) ->
72 ?CHECK(proper_spec_map_slow).
75 ?CHECK(proper_spec_map).
78 ?CHECK(proper_spec_map_3).
80 t_auto_unique_preserve_order(_Cfg) ->
81 ?CHECK(proper_spec_prop_unique_preserve_order).
83 t_auto_hope_list_specs(_Cfg) ->
84 [] = proper:check_specs(hope_list).
86 %% ============================================================================
88 %% ============================================================================
90 proper_spec_map_rev() ->
91 ?FORALL({L, F}, {type_l(), type_f()},
92 hope_list:map_rev(L, F) == lists:reverse(lists:map(F, L))
95 proper_spec_map_slow() ->
96 ?FORALL({L, F}, {type_l(), type_f()},
97 hope_list:map_slow(L, F) == lists:map(F, L)
101 ?FORALL({L, F}, {type_l(), type_f()},
102 hope_list:map(L, F) == lists:map(F, L)
105 proper_spec_map_3() ->
106 ?FORALL({L, F, N}, {type_l(), type_f(), ?type:non_neg_integer()},
107 hope_list:map(L, F, N) == lists:map(F, L)
110 proper_spec_prop_unique_preserve_order() ->
111 ?FORALL(L, ?type:list(),
113 Duplicates = L -- lists:usort(L),
114 hope_list:unique_preserve_order(L) ==
115 lists:reverse(lists:reverse(L) -- Duplicates)
119 ?type:list(?type:integer()).
122 ?type:function([?type:integer()], ?type:term()).