Copyright © Quviq AB, 2015-2023
Version: 1.46.3
Function generators that shrink to printable functions.
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
| function0/1 | Generate a function of arity 0. |
| function1/1 | Generate a function of arity 1. |
| function1/2 | Generate a function of arity 1 where the result generator can depend on the argument. |
| function2/1 | Generate a function of arity 2. |
| function2/2 | Two-argument dependent function generator. |
| function3/1 | Generate a function of arity 3. |
| function3/2 | Three-argument dependent function generator. |
| function4/1 | Generate a function of arity 4. |
| function4/2 | Four-argument dependent function generator. |
| function5/1 | Generate a function of arity 5. |
| function5/2 | Five-argument dependent function generator. |
| pretty_function/1 | Pretty print a function. |
| print_function/1 | Print a function. |
| print_function/2 | Print a function with a prefix. |
| show_function/1 | Show a function as a string. |
| show_function/2 | Show a function with a string prefix. |
function0(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun(() -> A))
Generate a function of arity 0.
function1(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any()) -> A))
Generate a function of arity 1.
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(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any()) -> A))
Generate a function of arity 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(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any(), any()) -> A))
Generate a function of arity 3.
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(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any(), any(), any()) -> A))
Generate a function of arity 4.
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(Gen::eqc_gen:gen(A)) -> eqc_gen:gen(fun((any(), any(), any(), any(), any()) -> A))
Generate a function of arity 5.
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(Fun::function()) -> prettypr:document()
Pretty print a function. Uses the prettypr library.
print_function(Fun::function()) -> ok
Equivalent to print_function("", Fun).
Print a function.
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(Fun::function()) -> string()
Equivalent to show_function("", Fun).
Show a function as a string.
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