1%%% -*- coding: utf-8 -*- 2%%% -*- erlang-indent-level: 2 -*- 3%%% ------------------------------------------------------------------- 4%%% Copyright 2010-2020 Manolis Papadakis <manopapad@gmail.com>, 5%%% Eirini Arvaniti <eirinibob@gmail.com> 6%%% and Kostis Sagonas <kostis@cs.ntua.gr> 7%%% 8%%% This file is part of PropEr. 9%%% 10%%% PropEr is free software: you can redistribute it and/or modify 11%%% it under the terms of the GNU General Public License as published by 12%%% the Free Software Foundation, either version 3 of the License, or 13%%% (at your option) any later version. 14%%% 15%%% PropEr is distributed in the hope that it will be useful, 16%%% but WITHOUT ANY WARRANTY; without even the implied warranty of 17%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18%%% GNU General Public License for more details. 19%%% 20%%% You should have received a copy of the GNU General Public License 21%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>. 22 23%%% @copyright 2010-2020 Manolis Papadakis, Eirini Arvaniti and Kostis Sagonas 24%%% @version {@version} 25%%% @author Eirini Arvaniti 26 27-module(error_statem). 28-export([command/1, initial_state/0, next_state/3, 29 precondition/2, postcondition/3, foo/1, bar/0]). 30 31-include_lib("proper/include/proper.hrl"). 32 33-record(state, {step = 0 :: non_neg_integer()}). 34 35initial_state() -> 36 #state{}. 37 38command(_S) -> 39 oneof([{call,?MODULE,foo,[integer()]}, 40 {call,?MODULE,bar,[]}]). 41 42precondition(_, _) -> 43 true. 44 45next_state(#state{step = Step}, _, _) -> 46 #state{step = Step+1}. 47 48postcondition(_, _, _) -> 49 true. 50 51foo(I) -> 52 case I > 10 of 53 false -> ok; 54 true -> throw(badarg) 55 end. 56 57bar() -> 42. 58 59prop_simple() -> 60 ?FORALL(Cmds, commands(?MODULE), 61 begin 62 {_H,_S,Res} = run_commands(?MODULE, Cmds), 63 equals(Res, ok) 64 end). 65