Implement hope_list:map_slow/2
[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 ]).
18
19
20-define(GROUP , hope_list).
21
22-define(PROPTEST(A), true = proper:quickcheck(A())).
23
24
25%% ============================================================================
26%% Common Test callbacks
27%% ============================================================================
28
29all() ->
30 [{group, ?GROUP}].
31
32groups() ->
33 Tests =
34 [ t_unique_preserve_order
35 , t_hope_list_specs
36 , t_map_rev
37 , t_map_slow
38 ],
39 Properties = [parallel],
40 [{?GROUP, Properties, Tests}].
41
42
43%% =============================================================================
44%% Test cases
45%% =============================================================================
46
47t_map_rev(_Cfg) ->
48 F = fun (N) -> N + 1 end,
49 [4, 3, 2] = hope_list:map_rev([1, 2, 3], F),
50 [] = hope_list:map_rev([], F).
51
52t_map_slow(_Cfg) ->
53 F = fun (N) -> N + 1 end,
54 [2, 3, 4] = hope_list:map_slow([1, 2, 3], F),
55 [] = hope_list:map_slow([], F).
56
57t_unique_preserve_order(_Cfg) ->
58 ?PROPTEST(prop_unique_preserve_order).
59
60prop_unique_preserve_order() ->
61 ?FORALL(L, list(),
62 begin
63 Duplicates = L -- lists:usort(L),
64 hope_list:unique_preserve_order(L) ==
65 lists:reverse(lists:reverse(L) -- Duplicates)
66 end).
67
68t_hope_list_specs(_) ->
69 [] = proper:check_specs(hope_list).
This page took 0.024971 seconds and 4 git commands to generate.