EQC.Component.Callouts
This module contains functions to be used with Quviq QuickCheck. It defines an Elixir version of the callout language found in eqc/include/eqc_component.hrl
. For detailed documentation of the macros, please refer to the QuickCheck documentation.
Copyright (C) Quviq AB, 2014-2015.
Summary↑
__SELF__() | Access the pid of the process executing an operation |
__VAR__() | Get access to (part of) an argument to a callout. For instance, |
assert(call) | Convenient syntax for assert |
assert(mod, fun, args) | Run-time assertion |
block() | Equivalent to block(SELF) |
block(tag) | Specify a blocking operation |
call(c) | Convenient syntax for |
call(fun, args) | Call a local command from a callout |
call(mod, fun, args) | Call a command from a callout |
callout(call, opts) | Convenient syntax for |
callout(mod, fun, args, res) | Specify a callout |
callouts(c) | Indicate that the following code is using the callout specification language |
either(c1, c2) | A choice between two different callout specifications |
either(tag, c1, c2) | A choice between two different callout specifications where every choice with the same tag has to go the same way (left or right) |
exception(e) | Exception return value. Can be used as the return value for a callout to make it throw an exception |
fail(e) | Model failure |
guard(g, c) | Conditional callout specification |
match(e) | Bind the result of a callout or generator |
optional(c) | An optional callout specification. Equivalent to |
par(list) | A list of callout specications arbitrarily interleaved |
ret(x) | Specify the result of an operation |
send(pid, msg) | Model sending a message |
seq(list) | A list of callout specifications in sequence |
unblock(tag, res) | Unblocking a blocked operation |
Functions
Equivalent to block(SELF).
In Erlang: ?BLOCK
Specify a blocking operation.
In Erlang: ?BLOCK(Tag)
Call a command from a callout.
In Erlang: ?APPLY(Mod, Fun, Args)
.
Specify a callout.
In Erlang: ?CALLOUT(Mod, Fun, Args, Res)
.
A choice between two different callout specifications.
In Erlang: ?EITHER(Tag, C1, C2)
A choice between two different callout specifications where every choice with the same tag has to go the same way (left or right).
In Erlang: ?EITHER(Tag, C1, C2)
Model failure.
In Erlang: ?FAIL(E)
.
An optional callout specification. Equivalent to either(c, :empty)
.
In Erlang: ?OPTIONAL(C)
A list of callout specications arbitrarily interleaved.
In Erlang: ?PAR
Specify the result of an operation.
In Erlang: ?RET(X)
Model sending a message.
In Erlang: ?SEND(Pid, Msg)
A list of callout specifications in sequence.
In Erlang: ?SEQ
Unblocking a blocked operation.
In Erlang: ?UNBLOCK(Tag, Res)
Macros
Access the pid of the process executing an operation.
In Erlang: ?SELF
Get access to (part of) an argument to a callout. For instance,
match {val, :ok} = callout :mock.foo(some_arg, __VAR__), return: :ok
...
Argument values are returned in a tuple with the return value.
Use :_
to ignore a callout argument.
In Erlang: ?VAR
Convenient syntax for assert.
Usage:
assert mod.fun(e1, .., en)
Run-time assertion.
In Erlang: ?ASSERT(Mod, Fun, Args)
Convenient syntax for call
.
call m.f(e1, .., en)
call f(e1, .., en)
is equivalent to
call(m, f, [e1, .., en])
call(f, [e1, .., en])
Call a local command from a callout.
In Erlang: ?APPLY(Fun, Args)
.
Convenient syntax for callout
.
callout m.f(e1, .., en), return: res
is equivalent to
callout(m, f, [e1, .., en], res)
Indicate that the following code is using the callout specification language.
This is default for the _callouts
callback, but this information is lost in some constructions like list comprehensions or par/1
calls.
Usage:
callouts do
...
end
In Erlang: ?CALLOUTS(C1, .., CN)
Exception return value. Can be used as the return value for a callout to make it throw an exception.
In Erlang: ?EXCEPTION(e)
.
Conditional callout specification.
Usage:
guard g, do: c
Equivalent to:
case g do
true -> c
false -> :empty
end
In Erlang: ?WHEN(G, C)
Bind the result of a callout or generator.
Usage:
match pat = exp
match pat <- gen
In Erlang: ?MATCH(Pat, Exp)
or ?MATCH_GEN(Pat, Gen)
.