[erlang-questions] PropEr way to deal with recursive types
Kostis Sagonas
kostis@REDACTED
Sat Sep 10 15:06:06 CEST 2011
On 09/10/11 14:46, Motiejus Jakštys wrote:
> On Fri, Sep 09, 2011 at 05:10:30PM -0700, James Aimonetti wrote:
>> I tried limiting the proplist to 5 tuples, heavily weighting the
>> proplist_value union towards binary(), etc. When I run
>> "proper:module(json_tester).", I see a string of periods (varies how far
>> it gets), then the VM hangs and I have to get into the JCL to interrupt
>> the process. My assumption is that the generator is getting stuck
>> creating a big data structure, as CPU and memory increase rapidly.
>>
>> I've looked at three examples[1][2][3] that Fred Herbert shared but
>> haven't found the mental bridge between his examples and my attempt. I
>> don't doubt that I'm misusing or ignorant of the right functions or
>> macros in PropEr to make this easier.
>>
>> Any hints? :)
>>
>
> You can limit recursion depth as well. Just pass max_size to the
> proper:quickcheck() function. That helped me as I didn't have to write
> my own recursive generator. :)
The PropEr way to deal with recursive types is to delay writing your own
generators as long as possible. You can start with writing just the
recursive type definitions and use them as a "for free" generator. If
that proves not to be adequate for your application, you can try to
globally limit the recursion depth in the way suggested by Motiejus.
Only if even that is not enough (for some reason) should you try to
resort to ?SIZED, resize, ?LAZY, and friends.
If you encounter any problem at any point in the above we would like to
hear about it (preferably with a small test that exhibits the problem).
Please use either the proper@REDACTED address or github for that as not
all PropEr developers read erlang-questions.
> As the topic is quite similar, I would like to remind about creating
> custom types in PropEr.
> http://erlang.org/pipermail/erlang-questions/2011-August/060619.html
We are (slowly) working on this one...
Kostis
More information about the erlang-questions
mailing list