abstract datatype: domain(T)

Domain of values of type T.

abstract datatype: pick_fun(T)

Picks members of the `domain(T)`

. Return pair of `{domain(T),T}`

; the “output domain” is what will be used for shrinking the value.

abstract datatype: shrink_fun(T)

Shrinks members of the `domain(T)`

. Return pair of `{domain(T),T}`

; the “output domain” is what will be used for further shrinking the value.

`any() -> any()`

`atom() -> any()`

`atom(Size) -> any()`

`binary() -> any()`

`binary(Size) -> any()`

bool() -> domain(true | false)

The domain of booleans. Shrinks to false.

`char() -> any()`

`choose(M, N) -> any()`

domain(Name::any(), PickFun::pick_fun(T), ShrinkFun::shrink_fun(T)) -> domain(T)

Create custom domain.

This function allows you to create a custom domain with it's own

shrinking logic. For instance, the even numbers can be specified thus:

The domain itself (`Self`

in the above code) is passed as the first argument

to each invocation of both the picking and the shrinking functions.

Both the picking and the shrinking function must return a 2-tuple of the domain of the resulting value, and the value itself.

elements(L::[any()]) -> domain(any())

Generates a member of the list `L`

. Shrinks towards the first element of the list.

eval(Body::any()) -> any()

Equivalent to `eval([], Body)`

.

Evaluate `Body`

. Occurrences of `{call,M,F,A}`

is replaced by the result of calling `erlang:apply(M,F,A)`

, and occurrences of `{var,Name}`

in `Body`

are not substituted.

This is a plain function, not a compile_transform or anything like that, so nested functions are not traversed in the substitution. However, nested occurrences of `{call,M,F,A}`

are substituted as one would think: depth first, left-to-right.

eval(PropList::[{atom(), any()}], Body::any()) -> any()

Evaluate `Body`

, replacing occurrences of `{call,M,F,A}`

and `{var,N}`

. Occurrences of `{call,M,F,A}`

is replaced by `erlang:apply(M,F,A)`

, and `{var,Name}`

is replaced by the value with key `Name`

in `PropList`

.

Exceptions happening when calling `erlang:apply/3`

are not caught. If `Name`

is unbound i.e., `Name`

does not appear in `PropList`

or if `Name`

is not an atom, `{var,Name}`

is unchanged.

This is a plain function, not a compile_transform or anything like that, so nested functions are not traversed in the substitution. However, nested occurrences of `{call,M,F,A}`

are substituted as one would think: depth first, left-to-right.

`frequency(GenList) -> any()`

Choose domain from list [{Weight, Domain}, ...]

int() -> domain(integer())

list(ElemDom::domain(T)) -> domain([T])

Returns the domain of lists of the argument. For example, `list(int())`

yields the domain of lists of integers.

`non_empty(?DOM) -> any()`

`oneof(DomList) -> any()`

open(?BOX::box(T)) -> domain(T)

Open a box, yielding a domain which always generates the same value.

`peek(?BOX) -> any()`

pick(Dom::domain(T), SampleSize::pos_integer()) -> {domain(T), T}

The heart of the random structure generator; pick a value from the domain. Returns a pair of `{domain(T), T}`

where the first component describes the structure of the picked value.

real() -> domain(float())

`resize(Sz, Dom) -> any()`

return(Value::Type) -> domain(Type)

Returns the domain containing exactly `Value`

. Triq uses internally records of type `@`

; and so to avoid interpretation of such values you can wrap it with this. This would be the case if you have constants in your domains contain the atom `@`

. I.e., the following would break because Triq tries to interpret the `@`

:

To fix it, do like this:

sample(Dom::domain(T)) -> [T]

Generate a sample of output values from a generator.

sampleshrink(Domain::domain(any())) -> ok

Print a value generated by `Domain`

, followed by a sample of shrinkings.

For each line of successive output, it prints up to five samples of

shrinking. The first value on each like is used as the target for the next

round of shrinking.

seal(Dom::domain(T)) -> domain(box(T))

shrink(Domain::domain(T), Value::T) -> {domain(T), T}

The shrinking step function used internally in Triq.

Performs one single step of shrinking. If unsuccessful,

i.e. value cound not be shrunk, the output is equal to the input.

Takes a `Domain`

and a `Value`

from said domain, and shrinks the value within the constraints of the domain. The result is a tuple of a (possibly smaller) output domain, and the shrunken value.

`shrink_without_duplicates(Dom) -> any()`

sized(Fun::‘fun’((integer()) -> domain(T))) -> domain(T)

Support function for the ?SIZED macro.

tuple(ElemDom::domain(ElemType::any())) -> domain(tuple(ElemType))

`vector(Size, ElemDom) -> any()`

*Generated by EDoc, Nov 7 2010, 11:39:46.*