[erlang-questions] PropEr: specify custom types in ?SIZED() fun

Motiejus Jakštys desired.mta@REDACTED
Wed Aug 10 18:08:47 CEST 2011


I want to specify my custom type depending on recursion level of
generated input. Consider this simple example:

-module(properworks).
-include_lib("proper/include/proper.hrl").
-compile(export_all).

-type recursive() :: binary() | [recursive()].

sized_struct(Size) when Size > 10 ->
    binary();
sized_struct(_Size) ->
    recursive().

prop_simple() ->
    ?FORALL(_Item,
        ?SIZED(Size, sized_struct(Size)),
        begin
            true
        end
    ).


$ erlc -pz ~/nrms/deps/proper/ebin -I ~/nrms/deps/proper properworks.erl 
./properworks.erl:10: function recursive/0 undefined

How can I specify a custom data type for generation in sized_struct/1?
Built-in types work (binary() as in this example), but not mine.

I tried ?LAZY, union() wrappers, no success.

P.S. does PropEr have a mailing list? I would hang there if it did. :)
P.P.S thank you for creating PropEr. Amazing tool.

Regards,
Motiejus



More information about the erlang-questions mailing list