Implement hope_list:map_slow/2
[hope.git] / test / hope_list_SUITE.erl
CommitLineData
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
8dad2faf
SK
17 ]).
18
19
20-define(GROUP , hope_list).
21
f4780d18
PO
22-define(PROPTEST(A), true = proper:quickcheck(A())).
23
8dad2faf
SK
24
25%% ============================================================================
26%% Common Test callbacks
27%% ============================================================================
28
29all() ->
30 [{group, ?GROUP}].
31
32groups() ->
33 Tests =
34 [ t_unique_preserve_order
8bbf6f4d 35 , t_hope_list_specs
c66ddf80 36 , t_map_rev
2a81fbac 37 , t_map_slow
8dad2faf 38 ],
8bbf6f4d 39 Properties = [parallel],
8dad2faf
SK
40 [{?GROUP, Properties, Tests}].
41
42
43%% =============================================================================
44%% Test cases
45%% =============================================================================
46
c66ddf80
SK
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
2a81fbac
SK
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
8dad2faf 57t_unique_preserve_order(_Cfg) ->
f4780d18
PO
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).
8bbf6f4d
PO
67
68t_hope_list_specs(_) ->
69 [] = proper:check_specs(hope_list).
This page took 0.024883 seconds and 4 git commands to generate.