[erlang-questions] PropEr after test clean up

Hynek Vychodil <>
Mon May 25 19:23:03 CEST 2015


Well, this
https://github.com/pichi/erlgt/commit/d470433dfb8859eaa05381eeba74511a2ff4f6e5
is a little bit better but not a general solution at all. It is fragile and
complicated.

On Mon, May 25, 2015 at 6:45 PM, Hynek Vychodil <>
wrote:

> There is commit showing how ugly is resulting code
> https://github.com/pichi/erlgt/commit/47aa088658ca6ca1e39e9630cd188f46e685e27a
>
> On Mon, May 25, 2015 at 6:40 PM, Hynek Vychodil <>
> wrote:
>
>> It is exactly how I discovered this behaviour. See
>> https://github.com/pichi/erlgt/blob/ff3249893464f19765c74db2eae24273f15f66fd/src/gen_digraph.erl#L153
>>
>> When I implemented otp_digraph as a wrapper for digraph module
>> from stdlib I realised it doesn't work.
>>
>> On Mon, May 25, 2015 at 6:34 PM, Erik Søe Sørensen <>
>> wrote:
>>
>>> Would a try...after...end be any help?
>>> Den 25/05/2015 17.11 skrev "Hynek Vychodil" <>:
>>>
>>>> Hi,
>>>>
>>>> I bumped in the problem how clean up after property in PropEr. Let's
>>>> have simple property where I make ets table:
>>>>
>>>> prop_ets() ->
>>>>     ?FORALL(V, integer(),
>>>>         begin
>>>>             E = ets:new(),
>>>>             true = ets:insert(T, {V, ok}),
>>>>             equals([{V, ok}], ets:lookup(T, V))
>>>>         end
>>>>     ).
>>>>
>>>> How am I supposed to delete ets table? It is trickier than looks like.
>>>> The problem is when I want use another ?FORALL inside my property. The
>>>> conjunction/1 is the same problem. You can`t write
>>>>
>>>> prop_ets() ->
>>>>     ?FORALL(V, integer(),
>>>>         begin
>>>>             E = ets:new(),
>>>>             true = ets:insert(T, {V, ok}),
>>>>             Res = conjunction([{lookup, equals([{V, ok}], ets:lookup(T,
>>>> V))},
>>>>                               {lookup_element,
>>>> equals(ok, ets:lookup_element(T, V, 2))}]),
>>>>             ets:delete(T),
>>>>             Res
>>>>         end
>>>>     ).
>>>>
>>>> Because Res is test(). In this case, you can make calls to
>>>> the ets:lookup/2 and the ets:lookup_element/3 before conjunction/1 but it
>>>> doesn't solve properties like
>>>>
>>>> ?FORALL(L, list(...),
>>>>     begin
>>>>         T = ets:new(),
>>>>         ...
>>>>         ?FORALL(V, oneof(L),
>>>>               ...
>>>>         )
>>>>      end
>>>> )
>>>>
>>>> The solution would be simple is every test case would be run in a
>>>> separate process, but it is not! It is very unusual in Erlang word to make
>>>> such thing. Processes are cheap and I can they are in a defined state each
>>>> run for free. Why is it all running in the same process?
>>>>
>>>> Has anybody solved this problem somehouw?
>>>>
>>>> Hynek Vychodil
>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> 
>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>>
>>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150525/acfa7afc/attachment.html>


More information about the erlang-questions mailing list