Commit | Line | Data |
---|---|---|
8dad2faf SK |
1 | -module(hope_list_SUITE). |
2 | ||
f4780d18 PO |
3 | -include_lib("proper/include/proper.hrl"). |
4 | ||
8dad2faf SK |
5 | %% Callbacks |
6 | -export( | |
7 | [ all/0 | |
8 | , groups/0 | |
9 | ]). | |
10 | ||
11 | %% Test cases | |
12 | -export( | |
13 | [ t_unique_preserve_order/1 | |
8bbf6f4d | 14 | , t_hope_list_specs/1 |
c66ddf80 | 15 | , t_map_rev/1 |
2a81fbac | 16 | , t_map_slow/1 |
ff793acf | 17 | , t_map/1 |
fad0cddc | 18 | , t_map_3/1 |
8dad2faf SK |
19 | ]). |
20 | ||
21 | ||
22 | -define(GROUP , hope_list). | |
23 | ||
f4780d18 PO |
24 | -define(PROPTEST(A), true = proper:quickcheck(A())). |
25 | ||
8dad2faf SK |
26 | |
27 | %% ============================================================================ | |
28 | %% Common Test callbacks | |
29 | %% ============================================================================ | |
30 | ||
31 | all() -> | |
32 | [{group, ?GROUP}]. | |
33 | ||
34 | groups() -> | |
35 | Tests = | |
36 | [ t_unique_preserve_order | |
8bbf6f4d | 37 | , t_hope_list_specs |
c66ddf80 | 38 | , t_map_rev |
2a81fbac | 39 | , t_map_slow |
ff793acf | 40 | , t_map |
fad0cddc | 41 | , t_map_3 |
8dad2faf | 42 | ], |
8bbf6f4d | 43 | Properties = [parallel], |
8dad2faf SK |
44 | [{?GROUP, Properties, Tests}]. |
45 | ||
46 | ||
47 | %% ============================================================================= | |
48 | %% Test cases | |
49 | %% ============================================================================= | |
50 | ||
c66ddf80 | 51 | t_map_rev(_Cfg) -> |
886a9557 PO |
52 | ?PROPTEST(map_rev). |
53 | ||
54 | map_rev() -> | |
55 | ?FORALL({L, F}, {list(integer()), function([integer()], term())}, | |
56 | hope_list:map_rev(L, F) == lists:reverse(lists:map(F, L))). | |
c66ddf80 | 57 | |
2a81fbac | 58 | t_map_slow(_Cfg) -> |
886a9557 PO |
59 | ?PROPTEST(map_slow). |
60 | ||
61 | map_slow() -> | |
62 | ?FORALL({L, F}, {list(integer()), function([integer()], term())}, | |
63 | hope_list:map_slow(L, F) == lists:map(F, L)). | |
2a81fbac | 64 | |
ff793acf | 65 | t_map(_Cfg) -> |
886a9557 PO |
66 | ?PROPTEST(map). |
67 | ||
68 | map() -> | |
69 | ?FORALL({L, F}, {list(integer()), function([integer()], term())}, | |
70 | hope_list:map(L, F) == lists:map(F, L)). | |
ff793acf | 71 | |
fad0cddc PO |
72 | t_map_3(_Cfg) -> |
73 | ?PROPTEST(map_3). | |
74 | ||
75 | map_3() -> | |
76 | ?FORALL({L, F, N}, {list(integer()), function([integer()], term()), non_neg_integer()}, | |
77 | hope_list:map(L, F, N) == lists:map(F, L)). | |
78 | ||
8dad2faf | 79 | t_unique_preserve_order(_Cfg) -> |
f4780d18 PO |
80 | ?PROPTEST(prop_unique_preserve_order). |
81 | ||
82 | prop_unique_preserve_order() -> | |
83 | ?FORALL(L, list(), | |
84 | begin | |
85 | Duplicates = L -- lists:usort(L), | |
86 | hope_list:unique_preserve_order(L) == | |
87 | lists:reverse(lists:reverse(L) -- Duplicates) | |
88 | end). | |
8bbf6f4d PO |
89 | |
90 | t_hope_list_specs(_) -> | |
91 | [] = proper:check_specs(hope_list). |