Module proper_erlang_abstract_code

PropEr generator of abstract code.

Description

PropEr generator of abstract code

This module is a PropEr generator for abstract code. It generates guards, expressions, programs (modules), and terms. It does not generate macros or other attributes than function, record, spec, and type. The generated programs (guards, expressions) can be used for testing the Compiler or other modules traversing programs as abstract forms. Typical examples of the latter are erl_eval, erl_pp, erl_prettypr (Syntax Tools), and parse transforms. Created modules should compile without errors, but will most likely crash immediately when invoked.

This is an example how to test the Compiler:

   test() ->
       ?FORALL(Abstr, proper_erlang_abstract_code:module(),
               ?WHENFAIL(
                  begin
                      io:format("~ts\n", [[erl_pp:form(F) || F <- Abstr]]),
                      compile(Abstr, [report_errors])
                  end,
                  case compile(Abstr, []) of
                      {error, _Es, _Ws} -> false;
                      _ -> true
                  end)).
  
   compile(Abstr, Opts) ->
       compile:noenv_forms(Abstr, Opts).

Data Types

atom_fun()

atom_fun() = fun(() -> proper_types:type())

A function that generates atoms. The default function chooses from 100 common English words.

char_fun()

char_fun() = fun(() -> proper_types:type())

A function that generates characters. The default function chooses from $a..$z | $A..$Z.

limit()

limit() = non_neg_integer()

option()

option() = {variables, [atom()]} | {weight, {Key::atom(), Weight::weight()}} | {function, [{FunctionName::atom(), Arity::arity()}]} | {types, [{TypeName::atom(), NumOfParms::arity()}]} | {records, [{RecordName::atom(), [FieldName::atom()]}]} | {limit, [{Name::atom(), Limit::limit()}]} | {char, char_fun()} | {atom, atom_fun()} | {set_all_weights, weight()}

See description below.

weight()

weight() = non_neg_integer()

Function Index

expr/0Returns abstract code of an expression.
expr/1Same as expr/0, but accepts a list of options.
guard/0Returns abstract code of a guard.
guard/1Same as guard/0, but accepts a list of options.
module/0Returns abstract code of a module.
module/1Same as module/0, but accepts a list of options.
term/0Returns abstract code of a term that can be handled by erl_parse:normalise/0.
term/1Same as term/0, but accepts a list of options.

Function Details

expr/0

expr() -> proper_types:type()

Returns abstract code of an expression.

expr/1

expr(Options::list()) -> proper_types:type()

Same as expr/0, but accepts a list of options. See module/1 for a description of the options.

guard/0

guard() -> proper_types:type()

Returns abstract code of a guard. A guard is a sequence of guard tests.

guard/1

guard(Options::[option()]) -> proper_types:type()

Same as guard/0, but accepts a list of options. See module/1 for a description of the options.

module/0

module() -> proper_types:type()

Returns abstract code of a module. The module has type declarations, functions, function specifications, and record declarations.

module/1

module(Options::[option()]) -> proper_types:type()

Same as module/0, but accepts a list of options.

Options

term/0

term() -> proper_types:type()

Returns abstract code of a term that can be handled by erl_parse:normalise/0.

term/1

term(Options::[option()]) -> proper_types:type()

Same as term/0, but accepts a list of options.

Options

Many options are the same as the ones for module/1.


Generated by EDoc