Skip to content

Commit 35ea333

Browse files
committed
seed: introduce seed user option
1 parent ae71f5f commit 35ea333

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/proper.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@
240240
%%% <dd>This is equivalent to the {@link numtests/1} property wrapper. Any
241241
%%% {@link numtests/1} wrappers in the actual property will overwrite this
242242
%%% setting.</dd>
243+
%%% <dt>`{seed, {<Non_negative_integer>,<Non_negative_integer>,<Non_negative_integer>}}'</dt>
244+
%%% <dd>Pass a seed to the RNG so that random results can be reproduced.</dd>
243245
%%% <dt>`{start_size, <Size>}'</dt>
244246
%%% <dd>Specifies the initial value of the `size' parameter (default is 1), see
245247
%%% the documentation of the {@link proper_types} module for details.</dd>
@@ -501,6 +503,7 @@
501503
| {'search_steps',pos_integer()}
502504
| {'search_strategy', atom()}
503505
| pos_integer()
506+
| {'seed',seed()}
504507
| {'start_size',size()}
505508
| {'max_size',size()}
506509
| {'max_shrinks',non_neg_integer()}
@@ -931,6 +934,7 @@ parse_opt(UserOpt, Opts) ->
931934
{search_steps, N} -> Opts#opts{search_steps = N};
932935
{search_strategy, S} -> Opts#opts{search_strategy = S};
933936
N when is_integer(N) -> Opts#opts{numtests = N};
937+
{seed,Seed} -> Opts#opts{seed = Seed};
934938
{start_size,Size} -> Opts#opts{start_size = Size};
935939
{max_size,Size} -> Opts#opts{max_size = Size};
936940
{max_shrinks,N} -> Opts#opts{max_shrinks = N};

test/proper_tests.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,9 @@ options_test_() ->
10381038
[{constraint_tries,0}], true),
10391039
?_failsWith([12],
10401040
?FORALL(_,?SIZED(Size,integer(Size,Size)),false),
1041-
[{start_size,12}])].
1041+
[{start_size,12}]),
1042+
?_failsWith([2762], ?FORALL(_,integer(),false),
1043+
[{seed,{1526,530081,919799}},noshrink,{start_size,65536}])].
10421044

10431045
setup_prop() ->
10441046
?SETUP(fun () ->

0 commit comments

Comments
 (0)