[erlang-questions] Generating fake data with PropEr?

Kostis Sagonas <>
Thu Jan 23 17:50:49 CET 2014


On 01/23/2014 05:43 PM, David Welton wrote:
> Is there a way to simply use PropEr to generate some fake data?
>
> For instance proper_types:integer() returns some kind of generator.
> How do I grab an integer from that?

Not sure what you mean by "fake data", but probably you want to look at 
function proper_gen:pick/1.

For example:

1> {ok, Term1} = proper_gen:pick(proper_types:term()).
{ok,-4}
2> {ok, Term2} = proper_gen:pick(proper_types:term()).
{ok,[{},4,-4,{},'Ö\001º_?','ÁJ\017<é ']}
3> {ok, Term3} = proper_gen:pick(proper_types:term()).
{ok,<<175,33,22,98:7>>}
4> {ok, Term4} = proper_gen:pick(proper_types:term()).
{ok,{{{}},
      4.374964496007777,-10.012426131156456,'\200',5,31,
      6.465840726473675,'ì\211k',-6.991691962714067}}


You can of course pass to this function any type.

Kostis



More information about the erlang-questions mailing list