[erlang-questions] PropEr after test clean up

Hynek Vychodil vychodil.hynek@REDACTED
Tue May 26 20:02:00 CEST 2015

It is pretty simple. You can't make macro like

-define(FOO(Data, Operation),
    (fun(Obj) ->
        try Operation after delete(Obj) end

which will work with Operation containing ?FORALL, ?WHENFAIL, ... etc. That
is it. It is very simple. You can't even use Erlang idiom.

do_after(F) ->
    Pid = self(),
    spawn_link(fun() -> process_flag(trap_exit, true),
            receive {'EXIT', Pid, _} -> F() end

because it all runs in one process. You just can't make simple and reliable
clean up embedded in wrapper macro or function. You always have to make
explicit ugly procedural code

Objs = init(),

You simply can't make nice clean functional or function like wrapper. It is
ugly, repetitive, error-prone, procedural code. This is wrong. This is the
reason why we have
http://www.erlang.org/doc/apps/eunit/chapter.html#Fixtures in eunit!

On Tue, May 26, 2015 at 6:15 PM, Kostis Sagonas <kostis@REDACTED> wrote:

> On 05/26/2015 11:34 AM, Hynek Vychodil wrote:
>> I think you are missing the point. Let's demonstrate the problem in this
>> way. There is natural but not working way how to do it
>> There is the problem. There is no way you can write ?WITH_G macro
>> working with any of PropEr macros as a parameter. And it would have a
>> simple solution. Just spawn the process or add hooks for clean up.
>> I know it is possible to write it in a way it will work, but it prevents
>> to write it reliably and in structured way.
> It's quite possible I am missing the point -- the set of complicated
> macros you show do not make it easy (for me) to understand what the problem
> is and sadly I do not have any time to devote to deciphering them.  Perhaps
> a natural language description of the property you are trying to check
> would help (me) more than the macros you show.
> Anyway, all I wrote in my previous mail was that the pattern of first
> doing a set up action, then running a test that returns some result that
> you save in a variable, then performing a cleanup action and finally
> checking whether the result satisfies or falsifies the property you want
> your test to satisfy is so natural --to me at least-- and general that I
> cannot possibly see why it does not work in what you want to do.  But of
> course what's "natural" is not defined objectively.
> Kostis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150526/ab4e532f/attachment.htm>

More information about the erlang-questions mailing list