Module proper_gen

Generator subsystem and generators for basic types.

Copyright © 2010-2020 Manolis Papadakis, Eirini Arvaniti and Kostis Sagonas

Version: May 19 2021 06:40:24

Authors: Manolis Papadakis.

Description

Generator subsystem and generators for basic types.

You can use these functions to try out the random instance generation and shrinking subsystems.

CAUTION: These functions should never be used inside properties. They are meant for demonstration purposes only.

Data Types

alt_gens()

alt_gens() = fun(() -> [imm_instance()])

combine_fun()

combine_fun() = fun((instance()) -> imm_instance())

generator()

generator() = sized_generator() | typed_sized_generator() | nosize_generator() | typed_nosize_generator()

imm_instance()

imm_instance() = proper_types:raw_type() | instance() | {'$used', imm_instance(), imm_instance()} | {'$to_part', imm_instance()}

A value produced by the random instance generator.

instance()

instance() = term()

nosize_generator()

nosize_generator() = fun(() -> imm_instance())

plain_reverse_gen()

plain_reverse_gen() = fun((instance()) -> imm_instance())

reverse_gen()

reverse_gen() = plain_reverse_gen() | typed_reverse_gen()

seed()

seed() = {non_neg_integer(), non_neg_integer(), non_neg_integer()}

size()

size() = non_neg_integer()

sized_generator()

sized_generator() = fun((size()) -> imm_instance())

typed_nosize_generator()

typed_nosize_generator() = {typed, fun((proper_types:type()) -> imm_instance())}

typed_reverse_gen()

typed_reverse_gen() = {typed, fun((proper_types:type(), instance()) -> imm_instance())}

typed_sized_generator()

typed_sized_generator() = {typed, fun((proper_types:type(), size()) -> imm_instance())}

Function Index

pick/1Equivalent to pick(Type, 10).
pick/2Equivalent to pick(Type, Size, os:timestamp()).
pick/3Generates a random instance of Type, of size Size with seed Seed.
sample/1Equivalent to sample(Type, 10, 20).
sample/3Generates and prints one random instance of Type for each size from StartSize up to EndSize.
sampleshrink/1Equivalent to sampleshrink(Type, 10).
sampleshrink/2Generates a random instance of Type, of size Size, then shrinks it as far as it goes.

Function Details

pick/1

pick(Type::proper_types:raw_type()) -> {ok, instance()} | error

Equivalent to pick(Type, 10).

pick/2

pick(Type::proper_types:raw_type(), Size::size()) -> {ok, instance()} | error

Equivalent to pick(Type, Size, os:timestamp()).

pick/3

pick(Type::proper_types:raw_type(), Size::size(), Seed::seed()) -> {ok, instance()} | error

Generates a random instance of Type, of size Size with seed Seed.

sample/1

sample(Type::proper_types:raw_type()) -> ok

Equivalent to sample(Type, 10, 20).

sample/3

sample(Type::proper_types:raw_type(), StartSize::size(), EndSize::size()) -> ok

Generates and prints one random instance of Type for each size from StartSize up to EndSize.

sampleshrink/1

sampleshrink(Type::proper_types:raw_type()) -> ok

Equivalent to sampleshrink(Type, 10).

sampleshrink/2

sampleshrink(Type::proper_types:raw_type(), Size::size()) -> ok

Generates a random instance of Type, of size Size, then shrinks it as far as it goes. The value produced on each step of the shrinking process is printed on the screen.


Generated by EDoc