Skip to content

Commit

Permalink
Merge pull request #3 from eriksoe/master
Browse files Browse the repository at this point in the history
Misc. Triq improvements, inclusing statem fixes.
  • Loading branch information
krestenkrab committed Sep 8, 2011
2 parents 5612de7 + 3e96d90 commit d60828a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/triq.hrl
Expand Up @@ -60,6 +60,7 @@
%%
-import(?DOMAIN_MODULE, [list/1, tuple/1, int/0, real/0, elements/1, any/0, atom/0,
choose/2, bool/0, char/0, oneof/1, return/1, vector/2, binary/0, binary/1,
non_empty/1,
shrink_without_duplicates/1, resize/2, frequency/1]).


Expand Down
22 changes: 22 additions & 0 deletions include/triq_statem.hrl
@@ -0,0 +1,22 @@
%%
%% This file is part of Triq - Trifork QuickCheck
%%
%% Copyright (c) 2011 by Trifork
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%

-import(triq_statem, [commands/1,
run_commands/2, run_commands/3,
state_after/2,
prop_statem/1]).
4 changes: 3 additions & 1 deletion src/triq_dom.erl
Expand Up @@ -827,6 +827,8 @@ bound_shrink(#?DOM{kind=#bound_domain{dom1=Dom1,val1=Val1,dom2=Dom2,fun2=Fun,siz

%% @doc support function for `?LETSHRINK([X,...],[domain(),...],domain())'
%% @private
bindshrink(Dom,_Fun) when not is_list(Dom) ->
error(argument_to_LETSHRINK_macro_must_be_lists);
bindshrink(Dom,Fun) when is_function(Fun,1) ->
domain(letshrink,
fun(_,SampleSize) ->
Expand Down Expand Up @@ -1244,7 +1246,7 @@ eval(PropList, Tuple) when is_tuple(Tuple) ->
A = eval(PropList, Args),
erlang:apply(M,F,A);

[var, Name] when is_atom(Name) ->
[var, Name] when is_integer(Name) ->
case proplists:lookup(Name, PropList) of
none -> {var, Name};
{Name, Value} -> Value
Expand Down
4 changes: 2 additions & 2 deletions src/triq_statem.erl
Expand Up @@ -130,7 +130,7 @@ run_commands(Module,Commands,Env) ->
do_run_command(Commands, Env, Module, History, State) ->
case Commands of
[] ->
{History, State, ok};
{History, eval(Env,State), ok};

[{init,S}|Rest] ->
State2 = eval(Env, S),
Expand All @@ -153,7 +153,7 @@ do_run_command(Commands, Env, Module, History, State) ->
do_run_command(Rest, Env2, Module, History2, State2);

Other ->
{History, State, {postcondition, Other}}
{History, eval(Env,State), {postcondition, Other}}
end
end.

Expand Down

0 comments on commit d60828a

Please sign in to comment.