eunit question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

eunit question

Michael L Martin
Hi all,

I'm a bit perplexed about this one. eunit is giving me an "unexpected
success" when testing a function with guards.
The source code and the output from ./rebar eu are attached.
Any insight would be greatly appreciated.

Thanks,
Michael

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

test1.erl (640 bytes) Download Attachment
test1-eunit-test.txt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: eunit question

Kostis Sagonas-2
On 11/03/2015 02:21 AM, Michael Martin wrote:
>
> I'm a bit perplexed about this one. eunit is giving me an "unexpected
> success" when testing a function with guards.
> The source code and the output from ./rebar eu are attached.
> Any insight would be greatly appreciated.
>
> -spec test1(map(), binary()) -> map().
>
> test1(Data, Argument) when is_map(Data); is_binary(Argument) ->

You most likely want to put a ',' instead of a ';' in the guard.

Kostis
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: eunit question

Michael L Martin
Thanks, Kostis, that fixed it.
Very strange, though, as all my other functions have a ';' rather than a
',', and they all work.
I'm changing them all to commas now.

Thanks again!


On 11/02/2015 07:33 PM, Kostis Sagonas wrote:

> On 11/03/2015 02:21 AM, Michael Martin wrote:
>>
>> I'm a bit perplexed about this one. eunit is giving me an "unexpected
>> success" when testing a function with guards.
>> The source code and the output from ./rebar eu are attached.
>> Any insight would be greatly appreciated.
>>
>> -spec test1(map(), binary()) -> map().
>>
>> test1(Data, Argument) when is_map(Data); is_binary(Argument) ->
>
> You most likely want to put a ',' instead of a ';' in the guard.
>
> Kostis

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: eunit question

Gleb Vinogradov
Hi, Michael

No-no-no, you shouldn't change them all to commas!
They are different - comma act as AND, while semicolon act as OR. Good luck!

Gleb

2015-11-03 7:27 GMT+06:00 Michael Martin <[hidden email]>:
Thanks, Kostis, that fixed it.
Very strange, though, as all my other functions have a ';' rather than a ',', and they all work.
I'm changing them all to commas now.

Thanks again!



On 11/02/2015 07:33 PM, Kostis Sagonas wrote:
On 11/03/2015 02:21 AM, Michael Martin wrote:

I'm a bit perplexed about this one. eunit is giving me an "unexpected
success" when testing a function with guards.
The source code and the output from ./rebar eu are attached.
Any insight would be greatly appreciated.

-spec test1(map(), binary()) -> map().

test1(Data, Argument) when is_map(Data); is_binary(Argument) ->

You most likely want to put a ',' instead of a ';' in the guard.

Kostis

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: eunit question

Kenneth Lakin
On 11/02/2015 06:31 PM, Gleb Vinogradov wrote:
> Hi, Michael
>
> No-no-no, you shouldn't change them all to commas!
> They are different - comma act as AND, while semicolon act as OR.

Indeed! I suspect that these links might be useful:

http://erlang.org/doc/reference_manual/expressions.html#id83606
http://erlang.org/doc/reference_manual/functions.html#syntax




_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: eunit question

Michael L Martin
Thanks everyone.

In my case, commas are appropriate, semi-colons not. It's all working as expected now.

Thanks again!


On 11/03/2015 12:51 AM, Kenneth Lakin wrote:
On 11/02/2015 06:31 PM, Gleb Vinogradov wrote:
Hi, Michael

No-no-no, you shouldn't change them all to commas!
They are different - comma act as AND, while semicolon act as OR.
Indeed! I suspect that these links might be useful:

http://erlang.org/doc/reference_manual/expressions.html#id83606
http://erlang.org/doc/reference_manual/functions.html#syntax





_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions