OR construction in erlang ?

Olivier Sambourg olivier.sambourg@REDACTED
Wed Apr 13 10:15:36 CEST 2005


Great ! Just what I was looking for :) (with an extra parameter to
throw a specific error if it does not match)
Thanks a lot !

--
Olivier

On 4/13/05, Dan Gudmundsson <dgud@REDACTED> wrote:
> 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