OR construction in erlang ?
Dan Gudmundsson
dgud@REDACTED
Wed Apr 13 08:35:13 CEST 2005
Olivier writes:
> I guess I'll have to do that, but it is basically a case / catch syntax
> : how would you do it in this case:
>
> ...
> true = lists:member(Key, List),
> false = lists:member(Key2, List),
> ...
>
We use a macro in our tests like:
?match(true, lists:member(Key, List)),
?match(false, lists:member(Key2, List)),
-define(match(ExpectedRes,Expr),
fun() ->
AcTuAlReS = (catch (Expr)),
case AcTuAlReS of
ExpectedRes ->
?verbose("ok, ~n Result as expected:~p~n",[AcTuAlReS]),
{success,AcTuAlReS};
_ ->
?error("Not Matching Actual result was:~n ~p~n",
[AcTuAlReS]),
{fail,AcTuAlReS}
end
end()).
The nice thing with a macro is that you can also use ?MODULE,?LINE
to get the location.
/Dan
More information about the erlang-questions
mailing list