[erlang-questions] Dialyzer safe way to test failure

Robert Virding rvirding@REDACTED
Tue Dec 9 03:44:27 CET 2014


I have run into the same problem but I don't think there is anything you
can do about it. Dialyzer is quite rightly informing you that you have a
type error in your code, it is just unfortunate that that is what you are
trying to test.

Why are you checking your test suites?

Robert


On 7 December 2014 at 01:06, Jay Nelson <jay@REDACTED> wrote:

> The following tests in my common_test suite:
>
>     true = try ?TM:reserve(atom_to_list(Cache_Name), Cache_Module) catch
> error:function_clause -> true end,
>     true = try ?TM:reserve(Cache_Name, atom_to_list(Cache_Module)) catch
> error:function_clause -> true end,
>
> cause dialyzer to complain:
>
> cxy_cache_SUITE.erl:58: The call
> cxy_cache:reserve(string(),Cache_Module::atom()) will never return since
> the success typing is (atom(),atom()) -> atom() |
> {'error','already_exists'} and the contract is (Name,module()) -> Name |
> {'error','already_exists'} when is_subtype(Name,cache_name())
> cxy_cache_SUITE.erl:59: The call
> cxy_cache:reserve(Cache_Name::atom(),string()) will never return since the
> success typing is (atom(),atom()) -> atom() | {'error','already_exists'}
> and the contract is (Name,module()) -> Name | {'error','already_exists'}
> when is_subtype(Name,cache_name())
>
>
> Is there a better way to check for failure when a non-string is passed as
> an arg to a function
> that expects two atoms?
>
> jay
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141209/643c2703/attachment.htm>


More information about the erlang-questions mailing list