eqc_ex v1.4.2 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-2016.

Summary

Functions

Equivalent to block(SELF)

Specify a blocking operation

Call a command from a callout

Specify a callout

A choice between two different callout specifications

A choice between two different callout specifications where every choice with the same tag has to go the same way (left or right)

Model failure

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

A list of callout specications arbitrarily interleaved

Specify the result of an operation

Model sending a message

A list of callout specifications in sequence

Unblocking a blocked operation

Macros

Access the pid of the process executing an operation

Get access to (part of) an argument to a callout. For instance,

Convenient syntax for assert

Run-time assertion

Convenient syntax for call

Call a local command from a callout

Convenient syntax for callout

Indicate that the following code is using the callout specification language

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

Conditional callout specification

Bind the result of a callout or generator

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