Module eqc_fun

Function generators that shrink to printable functions.

Copyright © Quviq AB, 2015-2017

Version: 1.42.1

Description

Function generators that shrink to printable functions.

Example

Here is a very silly property that is obviously untrue.
  prop_silly() ->
    ?FORALL(F, eqc_fun:function1(nat()),
    ?WHENFAIL(print_function("F =", F),
    F(foo) == F("foo") orelse F(bar) == F("bar"))).
Running QuickCheck on it we get a nice counterexample:
  1> eqc:quickcheck(example:prop_silly()).
  ........Failed! After 9 tests.
  #Fun<eqc_fun.38.83612070>
  F = #Fun<eqc_fun.38.83612070>
  Shrinking ...
  #Fun<eqc_fun.38.83612070>
  F = fun(foo) -> 1;
         ("bar") -> 1;
         (_) -> 0 end
  false

Function Index

function0/1Generate a function of arity 0.
function1/1Generate a function of arity 1.
function1/2Generate a function of arity 1 where the result generator can depend on the argument.
function2/1Generate a function of arity 2.
function2/2Two-argument dependent function generator.
function3/1Generate a function of arity 3.
function3/2Three-argument dependent function generator.
function4/1Generate a function of arity 4.
function4/2Four-argument dependent function generator.
function5/1Generate a function of arity 5.
function5/2Five-argument dependent function generator.
pretty_function/1Pretty print a function.
print_function/1Print a function.
print_function/2Print a function with a prefix.
show_function/1Show a function as a string.
show_function/2Show a function with a string prefix.

Function Details

function0/1

function0(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun(() -> A))

Generate a function of arity 0.

function1/1

function1(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any()) -> A))

Generate a function of arity 1.

function1/2

function1(VGen::fun((A) -> eqc_gen:gen(B)), DGen::eqc_gen:gen(B)) -> eqc_gen:gen(fun((A) -> B))

Generate a function of arity 1 where the result generator can depend on the argument. The second argument is a non-dependent generator to use in the catch-all case.

function2/1

function2(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any()) -> A))

Generate a function of arity 2.

function2/2

function2(VGen::fun((A, B) -> eqc_gen:gen(C)), DGen::eqc_gen:gen(C)) -> eqc_gen:gen(fun((A, B) -> C))

Two-argument dependent function generator.

See also: function1/2.

function3/1

function3(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any(), any()) -> A))

Generate a function of arity 3.

function3/2

function3(VGen::fun((A, B, C) -> eqc_gen:gen(D)), DGen::eqc_gen:gen(D)) -> eqc_gen:gen(fun((A, B, C) -> D))

Three-argument dependent function generator.

See also: function1/2.

function4/1

function4(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any(), any(), any()) -> A))

Generate a function of arity 4.

function4/2

function4(VGen::fun((A, B, C, D) -> eqc_gen:gen(E)), DGen::eqc_gen:gen(E)) -> eqc_gen:gen(fun((A, B, C, D) -> E))

Four-argument dependent function generator.

See also: function1/2.

function5/1

function5(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any(), any(), any(), any()) -> A))

Generate a function of arity 5.

function5/2

function5(VGen::fun((A, B, C, D, E) -> eqc_gen:gen(F)), DGen::eqc_gen:gen(F)) -> eqc_gen:gen(fun((A, B, C, D, E) -> F))

Five-argument dependent function generator.

See also: function1/2.

pretty_function/1

pretty_function(Fun::function()) -> prettypr:document()

Pretty print a function. Uses the prettypr library.

print_function/1

print_function(Fun::function()) -> ok

Equivalent to print_function("", Fun).

Print a function.

print_function/2

print_function(Str::string(), Fun::function()) -> ok

Print a function with a prefix. Equivalent to io:format("~s\n", [show_function(Str, Fun)]).

show_function/1

show_function(Fun::function()) -> string()

Equivalent to show_function("", Fun).

Show a function as a string.

show_function/2

show_function(Str::string(), Fun::function()) -> string()

Show a function with a string prefix. Typical use 'show_function("Fun = ", Fun)'. Use instead of '"Fun =" ++ show_function(Fun)' to get the layout right.


Generated by EDoc, Sep 18 2017, 16:17:38.