Thanks. It seems that the actual return types of @test
don’t match the docstring, which doesn’t say anything about a Tuple
.
Returns a Pass
Result
if it does, a Fail
Result
if it is
false
, and an Error
Result
if it could not be evaluated.
eg
julia> VERSION
v"1.2.0-DEV.557"
julia> using Test
julia> @testset "example" begin
@show typeof(@test 1 == 1)
@show typeof(@test 1 == 2)
@show typeof(@test (1 - "a"))
end
typeof(#= REPL[15]:2 =# @test(1 == 1)) = Test.Pass
example: Test Failed at REPL[15]:3
Expression: 1 == 2
Evaluated: 1 == 2
Stacktrace:
[1] top-level scope at show.jl:573
[2] top-level scope at REPL[15]:3
[3] top-level scope at /home/tamas/src/julia-git/usr/share/julia/stdlib/v1.2/Test/src/Test.jl:1113
[4] top-level scope at REPL[15]:2
typeof(#= REPL[15]:3 =# @test(1 == 2)) = Tuple{Test.Fail,Array{Union{Ptr{Nothing}, Base.InterpreterIP},1}}
example: Error During Test at REPL[15]:4
Test threw exception
Expression: 1 - "a"
MethodError: no method matching -(::Int64, ::String)
Closest candidates are:
-(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at int.jl:51
-(::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, !Matched::T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:52
-(::Union{Int16, Int32, Int64, Int8}, !Matched::BigInt) at gmp.jl:470
...
Stacktrace:
[1] top-level scope at show.jl:573
[2] top-level scope at REPL[15]:4
[3] top-level scope at /home/tamas/src/julia-git/usr/share/julia/stdlib/v1.2/Test/src/Test.jl:1113
[4] top-level scope at REPL[15]:2
typeof(#= REPL[15]:4 =# @test(1 - "a")) = Tuple{Test.Error,Bool}
Test Summary: | Pass Fail Error Total
example | 1 1 1 3
ERROR: Some tests did not pass: 1 passed, 1 failed, 1 errored, 0 broken.
I think I will report an issue for this.