Use property tests for map, map_rev and map_slow
[hope.git] / test / hope_list_SUITE.erl
... / ...
CommitLineData
1-module(hope_list_SUITE).
2
3-include_lib("proper/include/proper.hrl").
4
5%% Callbacks
6-export(
7 [ all/0
8 , groups/0
9 ]).
10
11%% Test cases
12-export(
13 [ t_unique_preserve_order/1
14 , t_hope_list_specs/1
15 , t_map_rev/1
16 , t_map_slow/1
17 , t_map/1
18 ]).
19
20
21-define(GROUP , hope_list).
22
23-define(PROPTEST(A), true = proper:quickcheck(A())).
24
25
26%% ============================================================================
27%% Common Test callbacks
28%% ============================================================================
29
30all() ->
31 [{group, ?GROUP}].
32
33groups() ->
34 Tests =
35 [ t_unique_preserve_order
36 , t_hope_list_specs
37 , t_map_rev
38 , t_map_slow
39 , t_map
40 ],
41 Properties = [parallel],
42 [{?GROUP, Properties, Tests}].
43
44
45%% =============================================================================
46%% Test cases
47%% =============================================================================
48
49t_map_rev(_Cfg) ->
50 ?PROPTEST(map_rev).
51
52map_rev() ->
53 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
54 hope_list:map_rev(L, F) == lists:reverse(lists:map(F, L))).
55
56t_map_slow(_Cfg) ->
57 ?PROPTEST(map_slow).
58
59map_slow() ->
60 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
61 hope_list:map_slow(L, F) == lists:map(F, L)).
62
63t_map(_Cfg) ->
64 ?PROPTEST(map).
65
66map() ->
67 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
68 hope_list:map(L, F) == lists:map(F, L)).
69
70t_unique_preserve_order(_Cfg) ->
71 ?PROPTEST(prop_unique_preserve_order).
72
73prop_unique_preserve_order() ->
74 ?FORALL(L, list(),
75 begin
76 Duplicates = L -- lists:usort(L),
77 hope_list:unique_preserve_order(L) ==
78 lists:reverse(lists:reverse(L) -- Duplicates)
79 end).
80
81t_hope_list_specs(_) ->
82 [] = proper:check_specs(hope_list).
This page took 0.034905 seconds and 4 git commands to generate.