Skip to content

Commit b4a6374

Browse files
committed
Include map() as a PropEr type generator
While at it, remove the `?LAZY()` call from its body and also place some generators in the right -or at least same- order in proper.hrl and in proper_types.erl
1 parent 3bbd252 commit b4a6374

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

include/proper.hrl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%%% -*- coding: utf-8; erlang-indent-level: 2 -*-
22
%%% -------------------------------------------------------------------
3-
%%% Copyright 2010-2021 Manolis Papadakis <[email protected]>,
3+
%%% Copyright 2010-2022 Manolis Papadakis <[email protected]>,
44
%%% Eirini Arvaniti <[email protected]>,
55
%%% and Kostis Sagonas <[email protected]>
66
%%%
@@ -19,7 +19,7 @@
1919
%%% You should have received a copy of the GNU General Public License
2020
%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>.
2121

22-
%%% @copyright 2010-2021 Manolis Papadakis, Eirini Arvaniti, and Kostis Sagonas
22+
%%% @copyright 2010-2022 Manolis Papadakis, Eirini Arvaniti, and Kostis Sagonas
2323
%%% @version {@version}
2424
%%% @author Manolis Papadakis
2525
%%% @doc User header file: This file should be included in each file containing
@@ -58,8 +58,8 @@
5858

5959
-import(proper_types, [integer/0, non_neg_integer/0, pos_integer/0,
6060
neg_integer/0, range/2, float/0, non_neg_float/0,
61-
number/0, boolean/0, byte/0, char/0, list/0, tuple/0,
62-
string/0, wunion/1, term/0, timeout/0, arity/0]).
61+
number/0, boolean/0, arity/0, byte/0, char/0, list/0,
62+
tuple/0, map/0, string/0, term/0, timeout/0, wunion/1]).
6363
-import(proper_types, [int/0, nat/0, largeint/0, real/0, bool/0, choose/2,
6464
elements/1, oneof/1, frequency/1, return/1, default/2,
6565
orderedlist/1, function0/1, function1/1, function2/1,

src/proper_types.erl

+11-12
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,6 @@ function_is_instance(Type, X) ->
11131113
%% TODO: what if it's not a function we produced?
11141114
andalso equal_types(RetType, proper_gen:get_ret_type(X)).
11151115

1116-
%% @doc A map associating keys and values of unspecified types (of any term()).
1117-
-spec map() -> proper_types:type().
1118-
map() ->
1119-
?LAZY(map(any(), any())).
1120-
11211116
%% @doc A map whose keys are defined by the generator `K' and values
11221117
%% by the generator `V'.
11231118
-spec map(K::raw_type(), V::raw_type()) -> proper_types:type().
@@ -1177,6 +1172,10 @@ number() -> union([integer(), float()]).
11771172
-spec boolean() -> proper_types:type().
11781173
boolean() -> union(['false', 'true']).
11791174

1175+
%% @equiv integer(0, 255)
1176+
-spec arity() -> proper_types:type().
1177+
arity() -> integer(0, 255).
1178+
11801179
%% @equiv integer(0, 255)
11811180
-spec byte() -> proper_types:type().
11821181
byte() -> integer(0, 255).
@@ -1197,14 +1196,14 @@ list() -> list(any()).
11971196
-spec tuple() -> proper_types:type().
11981197
tuple() -> loose_tuple(any()).
11991198

1199+
%% @equiv map(any(), any())
1200+
-spec map() -> proper_types:type().
1201+
map() -> map(any(), any()).
1202+
12001203
%% @equiv list(char())
12011204
-spec string() -> proper_types:type().
12021205
string() -> list(char()).
12031206

1204-
%% @equiv weighted_union(FreqChoices)
1205-
-spec wunion([{frequency(),raw_type()},...]) -> proper_types:type().
1206-
wunion(FreqChoices) -> weighted_union(FreqChoices).
1207-
12081207
%% @equiv any()
12091208
-spec term() -> proper_types:type().
12101209
term() -> any().
@@ -1213,9 +1212,9 @@ term() -> any().
12131212
-spec timeout() -> proper_types:type().
12141213
timeout() -> union([non_neg_integer(), 'infinity']).
12151214

1216-
%% @equiv integer(0, 255)
1217-
-spec arity() -> proper_types:type().
1218-
arity() -> integer(0, 255).
1215+
%% @equiv weighted_union(FreqChoices)
1216+
-spec wunion([{frequency(),raw_type()},...]) -> proper_types:type().
1217+
wunion(FreqChoices) -> weighted_union(FreqChoices).
12191218

12201219

12211220
%%------------------------------------------------------------------------------

0 commit comments

Comments
 (0)