<div dir="ltr">It is pretty simple. You can't make macro like<div><br></div><div>-define(FOO(Data, Operation),</div><div> (fun(Obj) -></div><div> try Operation after delete(Obj) end</div><div> end)(new(Data))</div><div> ).</div><div><br></div><div>which will work with Operation containing ?FORALL, ?WHENFAIL, ... etc. That is it. It is very simple. You can't even use Erlang idiom.</div><div><br></div><div>do_after(F) -></div><div> Pid = self(),</div><div> spawn_link(fun() -> process_flag(trap_exit, true),</div><div> receive {'EXIT', Pid, _} -> F() end</div><div> end).</div><div><br></div><div>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</div><div><br></div><div>Objs = init(),</div><div>run(),</div><div>delete(Objs),</div><div>test()</div><div><br></div><div>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 <a href="http://www.erlang.org/doc/apps/eunit/chapter.html#Fixtures">http://www.erlang.org/doc/apps/eunit/chapter.html#Fixtures</a> in eunit!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 26, 2015 at 6:15 PM, Kostis Sagonas <span dir="ltr"><<a href="mailto:kostis@cs.ntua.gr" target="_blank">kostis@cs.ntua.gr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 05/26/2015 11:34 AM, Hynek Vychodil wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
I think you are missing the point. Let's demonstrate the problem in this<br>
way. There is natural but not working way how to do it<br></span>
... <COMPLICATED MACROS SNIPPED> ...<span class=""><br>
There is the problem. There is no way you can write ?WITH_G macro<br>
working with any of PropEr macros as a parameter. And it would have a<br>
simple solution. Just spawn the process or add hooks for clean up.<br>
<br>
I know it is possible to write it in a way it will work, but it prevents<br>
to write it reliably and in structured way.<br>
</span></blockquote>
<br>
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.<br>
<br>
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.<span class="HOEnZb"><font color="#888888"><br>
<br>
Kostis<br>
</font></span></blockquote></div><br></div>