Skip to content

Commit

Permalink
Merge pull request #31 from jhlywa/master
Browse files Browse the repository at this point in the history
More aggressive shrinker for choose/2
  • Loading branch information
krestenkrab committed Nov 17, 2014
2 parents fcf2773 + db97613 commit f440bc0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/triq_dom.erl
Expand Up @@ -1063,10 +1063,9 @@ choose_pick(#?DOM{kind=#choose{min=M,max=N}}=Dom, _) ->
Value = random:uniform(N-M+1) - 1 + M,
{Dom,Value}.

choose_shrink(#?DOM{kind=#choose{min=M}}=Dom, Value) when Value > M ->
{Dom,Value-1};
choose_shrink(#?DOM{kind=#choose{min=M}}=Dom, M) ->
{Dom,M}.
choose_shrink(#?DOM{kind=#choose{min=M}}=Dom, Value) ->
Mid = (Value - M) div 2,
{Dom, M + Mid}.

%% @doc Generates a member of the list `L'. Shrinks towards the first element
%% of the list.
Expand Down

0 comments on commit f440bc0

Please sign in to comment.