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

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

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 either(c, :empty)

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

block()

Equivalent to block(SELF).

In Erlang: ?BLOCK

block(tag)

Specify a blocking operation.

In Erlang: ?BLOCK(Tag)

call(mod, fun, args)

Call a command from a callout.

In Erlang: ?APPLY(Mod, Fun, Args).

callout(mod, fun, args, res)

Specify a callout.

In Erlang: ?CALLOUT(Mod, Fun, Args, Res).

either(c1, c2)

A choice between two different callout specifications.

In Erlang: ?EITHER(Tag, C1, C2)

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)

fail(e)

Model failure.

In Erlang: ?FAIL(E).

optional(c)

An optional callout specification. Equivalent to either(c, :empty).

In Erlang: ?OPTIONAL(C)

par(list)

A list of callout specications arbitrarily interleaved.

In Erlang: ?PAR

ret(x)

Specify the result of an operation.

In Erlang: ?RET(X)

send(pid, msg)

Model sending a message.

In Erlang: ?SEND(Pid, Msg)

seq(list)

A list of callout specifications in sequence.

In Erlang: ?SEQ

unblock(tag, res)

Unblocking a blocked operation.

In Erlang: ?UNBLOCK(Tag, Res)

Macros

__SELF__()

Access the pid of the process executing an operation.

In Erlang: ?SELF

__VAR__()

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

assert(call)

Convenient syntax for assert.

Usage:

assert mod.fun(e1, .., en)
assert(mod, fun, args)

Run-time assertion.

In Erlang: ?ASSERT(Mod, Fun, Args)

call(c)

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(fun, args)

Call a local command from a callout.

In Erlang: ?APPLY(Fun, Args).

callout(call, opts)

Convenient syntax for callout.

callout m.f(e1, .., en), return: res

is equivalent to

callout(m, f, [e1, .., en], res)
callouts(c)

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(e)

Exception return value. Can be used as the return value for a callout to make it throw an exception.

In Erlang: ?EXCEPTION(e).

guard(g, c)

Conditional callout specification.

Usage:

guard g, do: c

Equivalent to:

case g do
  true  -> c
  false -> :empty
end

In Erlang: ?WHEN(G, C)

match(e)

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).