Copyright © 2010-2016 Manolis Papadakis, Eirini Arvaniti and Kostis Sagonas
Version: Jun 20 2016 16:27:12
Authors: Manolis Papadakis.
Symbolic datatypes handling functions.
{call,sets,from_list,[[1,2,3]]}with:
{set,3,16,16,8,80,48, {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, {{[],[3],[],[],[],[],[2],[],[],[],[],[1],[],[],[],[]}}}
{call,Module,Function,Arguments}
Module:Function
with
arguments Arguments
. Each of the arguments may be a symbolic call itself
or contain other symbolic calls in lists or tuples of arbitrary
depth.{'$call',Module,Function,Arguments}
{var,
var_id()
}
When including the PropEr header file, all
API functions of this module are automatically
imported, unless PROPER_NO_IMPORTS
is defined.
To simplify the symbolic testing of ADTs, PropEr comes with the Auto-ADT
subsystem: An opaque native type, if exported from its module, is assumed
to be an abstract data type, causing PropEr to ignore its internal
representation and instead construct symbolic instances of the type. The
API functions used in these symbolic instances are extracted from the ADT's
defining module, which is expected to contain one or more -spec
ed and
exported functions that can be used to construct instances of the ADT.
Specifically, PropEr will use all functions that return at least one
instance of the ADT. As with recursive native types, the base case is
automatically detected (in the case of ADTs, calls to functions like
new/0
and from_list/1
would be considered the base case). The produced
symbolic calls will be $call
tuples, which are
automatically evaluated, thus no call to eval/1
is required inside
the property. Produced instances are guaranteed to evaluate successfully.
Parametric ADTs are supported, so long as they appear fully instantiated
inside ?FORALL
s.
ADTs hard-coded in the Erlang type system (array
, dict
, digraph
,
gb_set
, gb_tree
, queue
, and set
) are automatically detected and
handled as such. PropEr also accepts parametric versions of the above ADTs
in ?FORALL
s (array/1
, dict/2
, gb_set/1
, gb_tree/2
, queue/1
,
set/1
, also orddict/2
and ordset/1
). If you would like to use these
parametric versions in -type
and -spec
declarations as well, to better
document your code and facilitate spec testing, you can include the
complementary header file proper/include/proper_param_adts.hrl
, which
provides the corresponding -type
definitions. Please note that Dialyzer
currenty treats these the same way as their non-parametric counterparts.
-opaque
declaration, as in all types' declarations,
only type variables should be used as parameters in the LHS. None of
these variables can be the special _
variable and no variable should
appear more than once in the parameters._
variable is not allowed in ADT parameters. If this would result in
singleton variables, as in the specs of functions like new/0
, use
variable names that begin with an underscore.-spec foo(mydict(T,S),mydict(S,T)) -> mydict(T,S).This includes using the same type variable twice in the parameters of an ADT.
is_subtype
constraints whose
first argument is a simple, non-_
variable. It is not checked whether or
not these variables actually appear in the spec. The second argument of an
is_subtype
constraint cannot contain any non-_
variables. Multiple
constraints for the same variable are not supported.examples/stack
module, which contains a simple implementation of a
stack, or the proper/proper_dict module
, which wraps the STDLIB
dict
ADT.
abstract datatype: symb_term()
var_id() = atom() | pos_integer()
var_values() = [{var_id(), term()}]
defined/1 | Returns true if the SymbTerm symbolic instance can be successfully
evaluated (its evaluation doesn't raise an error or exception). |
eval/1 | Equivalent to eval([], SymbTerm). |
eval/2 | Intended for use inside the property-testing code, this function
evaluates a symbolic instance SymbTerm . |
pretty_print/1 | Equivalent to pretty_print([], SymbTerm). |
pretty_print/2 | Similar in calling convention to eval/2 , but returns a string
representation of the call sequence SymbTerm instead of evaluating it. |
well_defined/1 | An attribute which can be applied to any symbolic generator SymbType
that may produce invalid sequences of operations when called. |
defined(SymbTerm :: symb_term()) -> boolean()
Returns true if the SymbTerm
symbolic instance can be successfully
evaluated (its evaluation doesn't raise an error or exception).
eval(SymbTerm :: symb_term()) -> term()
Equivalent to eval([], SymbTerm).
eval(VarValues :: var_values(), SymbTerm :: symb_term()) -> term()
Intended for use inside the property-testing code, this function
evaluates a symbolic instance SymbTerm
. It also accepts a proplist
VarValues
that maps variable names to values, which is used to replace any
var tuples inside SymbTerm
before proceeding with its
evaluation.
pretty_print(SymbTerm :: symb_term()) -> string()
Equivalent to pretty_print([], SymbTerm).
pretty_print(VarValues :: var_values(), SymbTerm :: symb_term()) -> string()
Similar in calling convention to eval/2
, but returns a string
representation of the call sequence SymbTerm
instead of evaluating it.
well_defined(SymbType :: proper_types:raw_type()) -> proper_types:type()
An attribute which can be applied to any symbolic generator SymbType
that may produce invalid sequences of operations when called. The resulting
generator is guaranteed to only produce well-defined symbolic instances.
Generated by EDoc, Jun 20 2016, 16:27:12.