1%%% -*- coding: utf-8 -*- 2%%% -*- erlang-indent-level: 2 -*- 3%%% ------------------------------------------------------------------- 4%%% Copyright 2010-2017 Manolis Papadakis <manopapad@gmail.com>, 5%%% Eirini Arvaniti <eirinibob@gmail.com>, 6%%% Kostis Sagonas <kostis@cs.ntua.gr>, 7%%% and Andreas Löscher <andreas.loscher@it.uu.se> 8%%% 9%%% This file is part of PropEr. 10%%% 11%%% PropEr is free software: you can redistribute it and/or modify 12%%% it under the terms of the GNU General Public License as published by 13%%% the Free Software Foundation, either version 3 of the License, or 14%%% (at your option) any later version. 15%%% 16%%% PropEr is distributed in the hope that it will be useful, 17%%% but WITHOUT ANY WARRANTY; without even the implied warranty of 18%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19%%% GNU General Public License for more details. 20%%% 21%%% You should have received a copy of the GNU General Public License 22%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>. 23 24%%% @copyright 2010-2017 Manolis Papadakis, Eirini Arvaniti, Kostis Sagonas and Andreas Löscher 25%%% @version {@version} 26%%% @author Manolis Papadakis 27%%% @doc Common parts of user and internal header files 28 29 30%%------------------------------------------------------------------------------ 31%% Test generation macros 32%%------------------------------------------------------------------------------ 33 34-define(FORALL(X,RawType,Prop), proper:forall(RawType, fun(X) -> Prop end)). 35-define(EXISTS(X,RawType,Prop), proper:exists(RawType, fun(X) -> Prop end, false)). 36-define(NOT_EXISTS(X,RawType,Prop), proper:exists(RawType, fun(X) -> Prop end, true)). 37-define(FORALL_TARGETED(X, RawType, Prop), 38 proper:targeted(RawType, fun(X) -> Prop end)). 39-define(IMPLIES(Pre,Prop), proper:implies(Pre,?DELAY(Prop))). 40-define(WHENFAIL(Action,Prop), proper:whenfail(?DELAY(Action),?DELAY(Prop))). 41-define(TRAPEXIT(Prop), proper:trapexit(?DELAY(Prop))). 42-define(TIMEOUT(Limit,Prop), proper:timeout(Limit,?DELAY(Prop))). 43-define(SETUP(SetupFun,Prop), proper:setup(SetupFun,Prop)). 44%% TODO: -define(ALWAYS(Tests,Prop), proper:always(Tests,?DELAY(Prop))). 45%% TODO: -define(SOMETIMES(Tests,Prop), proper:sometimes(Tests,?DELAY(Prop))). 46 47%%------------------------------------------------------------------------------ 48%% Generator macros 49%%------------------------------------------------------------------------------ 50 51-define(FORCE(X), (X)()). 52-define(DELAY(X), fun() -> X end). 53-define(LAZY(X), proper_types:lazy(?DELAY(X))). 54-define(SIZED(SizeArg,Gen), proper_types:sized(fun(SizeArg) -> Gen end)). 55-define(LET(X,RawType,Gen), proper_types:bind(RawType,fun(X) -> Gen end,false)). 56-define(SHRINK(Gen,AltGens), 57 proper_types:shrinkwith(?DELAY(Gen),?DELAY(AltGens))). 58-define(LETSHRINK(Xs,RawType,Gen), 59 proper_types:bind(RawType,fun(Xs) -> Gen end,true)). 60-define(SUCHTHAT(X,RawType,Condition), 61 proper_types:add_constraint(RawType,fun(X) -> Condition end,true)). 62-define(SUCHTHATMAYBE(X,RawType,Condition), 63 proper_types:add_constraint(RawType,fun(X) -> Condition end,false)). 64 65%%------------------------------------------------------------------------------ 66%% Targeted macros 67%%------------------------------------------------------------------------------ 68 69-define(MAXIMIZE(Fitness), proper_target:update_uv(Fitness, inf)). 70-define(MINIMIZE(Fitness), ?MAXIMIZE(-Fitness)). 71-define(USERNF(Type, NF), proper_gen_next:set_user_nf(Type, NF)). 72-define(USERMATCHER(Type, Matcher), proper_gen_next:set_matcher(Type, Matcher)). 73