throw should be throwing an exception rather than just a string, which is 
why the deprecation message is a bit confusing.

So instead of the line 
https://github.com/diegozea/MIToS.jl/blob/master/src/MSA/IndexedVectors.jl#L49 
you’d want to have something like

throw(ArgumentError("$element is more than one time in the vector."))

or some other error type rather than ArgumentError if that’s not 
appropriate for the situation. See the docs, 
http://docs.julialang.org/en/latest/manual/control-flow/#the-throw-function, 
for a list of all the builtin ones.

Then in your tests you can do

@test_throws ArgumentError IndexedVector([1, 2, 3, 3])

— Mike
​
On Thursday, 6 August 2015 04:51:33 UTC+2, Diego Javier Zea wrote:
>
>
> *What is the correct way for testing*
>  throw(message)
> *?*
>
> *I'm getting this errors using test_throws. ¿What am I doing wrong? The 
> deprecation message is confusing.*
>
> julia> using Base.Test
>
>
> julia> IndexedVector([1,2,3,3])
> ERROR: "3 is more than one time in the vector."
>  in call at /home/dzea/.julia/v0.4/MIToS/src/MSA/IndexedVectors.jl:39
>
>
> julia> @test_throws IndexedVector([1,2,3,3])
> WARNING: @test_throws without an exception type is deprecated;
> Use `@test_throws ASCIIString IndexedVector([1,2,3,3])` instead.
>  in backtrace at error.jl:26
> "3 is more than one time in the vector."
>
>
> julia> @test_throws "3 is more than one time in the vector." IndexedVector
> ([1,2,3,3])
> ERROR: TypeError: isa: expected Type{T}, got ASCIIString
>  in do_test_throws at test.jl:69
>
>
> *Thanks!*
>

Reply via email to