Skip to content

Commit

Permalink
Fixed some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
apaz-cli authored and maleadt committed Nov 18, 2022
1 parent ab88ba3 commit dc4d8a1
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,21 +374,21 @@ let err_str,
j = reinterpret(EightBitTypeT{Int32}, 0x54)

err_str = @except_str Bool() MethodError
@test occursin("MethodError: no method matching Bool()", err_str)
@test occursin("MethodError: no method matching for call to Bool()", err_str)
err_str = @except_str :a() MethodError
@test occursin("MethodError: objects of type Symbol are not callable", err_str)
err_str = @except_str EightBitType() MethodError
@test occursin("MethodError: no method matching $(curmod_prefix)EightBitType()", err_str)
@test occursin("MethodError: no method matching for call to $(curmod_prefix)EightBitType()", err_str)
err_str = @except_str i() MethodError
@test occursin("MethodError: objects of type $(curmod_prefix)EightBitType are not callable", err_str)
err_str = @except_str EightBitTypeT() MethodError
@test occursin("MethodError: no method matching $(curmod_prefix)EightBitTypeT()", err_str)
@test occursin("MethodError: no method matching for call to $(curmod_prefix)EightBitTypeT()", err_str)
err_str = @except_str EightBitTypeT{Int32}() MethodError
@test occursin("MethodError: no method matching $(curmod_prefix)EightBitTypeT{Int32}()", err_str)
@test occursin("MethodError: no method matching for call to $(curmod_prefix)EightBitTypeT{Int32}()", err_str)
err_str = @except_str j() MethodError
@test occursin("MethodError: objects of type $(curmod_prefix)EightBitTypeT{Int32} are not callable", err_str)
err_str = @except_str FunctionLike()() MethodError
@test occursin("MethodError: no method matching (::$(curmod_prefix)FunctionLike)()", err_str)
@test occursin("MethodError: no method matching for call to (::$(curmod_prefix)FunctionLike)()", err_str)
err_str = @except_str [1,2](1) MethodError
@test occursin("MethodError: objects of type Vector{$Int} are not callable\nUse square brackets [] for indexing an Array.", err_str)
# Issue 14940
Expand All @@ -401,10 +401,10 @@ end
# Issue 34636
let err_str
err_str = @except_str 1 + rand(5) MethodError
@test occursin("MethodError: no method matching +(::$Int, ::Vector{Float64})", err_str)
@test occursin("MethodError: no method matching for call to +(::$Int, ::Vector{Float64})", err_str)
@test occursin("For element-wise addition, use broadcasting with dot syntax: scalar .+ array", err_str)
err_str = @except_str rand(5) - 1//3 MethodError
@test occursin("MethodError: no method matching -(::Vector{Float64}, ::Rational{$Int})", err_str)
@test occursin("MethodError: no method matching for call to -(::Vector{Float64}, ::Rational{$Int})", err_str)
@test occursin("For element-wise subtraction, use broadcasting with dot syntax: array .- scalar", err_str)
end

Expand Down Expand Up @@ -558,7 +558,7 @@ let
# one constructor defined?
EnclosingModule.AbstractTypeNoConstructors(x, y) = x + y
@test startswith(sprint(showerror, method_error),
"MethodError: no method matching $(EnclosingModule.AbstractTypeNoConstructors)()")
"MethodError: no method matching for call to $(EnclosingModule.AbstractTypeNoConstructors)()")

# Test that the 'default' sysimg.jl method is not displayed.
@test !occursin("where T at sysimg.jl", sprint(showerror, method_error))
Expand All @@ -582,14 +582,14 @@ end
e
end::MethodError
str = sprint(Base.showerror, ex1)
@test startswith(str, "MethodError: no method matching f21006(::Tuple{})")
@test startswith(str, "MethodError: no method matching for call to f21006(::Tuple{})")
@test !occursin("The applicable method may be too new", str)

# If newer applicable methods are available, world age should be mentioned.
f21006(x) = x
@test f21006(()) === ()
str = sprint(Base.showerror, ex1)
@test startswith(str, "MethodError: no method matching f21006(::Tuple{})")
@test startswith(str, "MethodError: no method matching for call to f21006(::Tuple{})")
@test occursin("The applicable method may be too new: running in world age $(ex1.world)", str)

# This method error should be thrown in a world new enough for `f21006(())`.
Expand All @@ -600,15 +600,15 @@ end
e
end::MethodError
str = sprint(Base.showerror, ex2)
@test startswith(str, "MethodError: no method matching f21006(::Tuple{}, ::Tuple{})")
@test startswith(str, "MethodError: no method matching for call to f21006(::Tuple{}, ::Tuple{})")
@test !occursin("The applicable method may be too new", str)

# If the method is available in the exception world or if the exception world is invalid,
# don't warn about world age
for ex3 in (MethodError(ex1.f, ex1.args, ex2.world),
MethodError(ex1.f, ex1.args, typemax(UInt)))
str = sprint(Base.showerror, ex3)
@test startswith(str, "MethodError: no method matching f21006(::Tuple{})")
@test startswith(str, "MethodError: no method matching for call to f21006(::Tuple{})")
@test !occursin("The applicable method may be too new", str)
end
end
Expand All @@ -627,10 +627,10 @@ end
@test Base.Experimental.register_error_hint(recommend_oneunit, MethodError) === nothing
let err_str
err_str = @except_str one(HasNoOne()) MethodError
@test occursin(r"MethodError: no method matching one\(::.*HasNoOne\)", err_str)
@test occursin(r"MethodError: no method matching for call to one\(::.*HasNoOne\)", err_str)
@test occursin("HasNoOne does not support `one`; did you mean `oneunit`?", err_str)
err_str = @except_str one(HasNoOne(); value=2) MethodError
@test occursin(Regex("MethodError: no method matching one\\(::.*HasNoOne; value::$(Int)\\)"), err_str)
@test occursin(Regex("MethodError: no method matching for call to one\\(::.*HasNoOne; value::$(Int)\\)"), err_str)
@test occursin("`one` doesn't take keyword arguments, that would be silly", err_str)
end
pop!(Base.Experimental._hint_handlers[MethodError]) # order is undefined, don't copy this
Expand Down Expand Up @@ -936,5 +936,5 @@ end

@testset "issue #47559" begin
err = try; invoke(Returns, Tuple{Any,Val{N}} where N, 1, Val(1)) catch ex; ex; end
@test startswith(sprint(Base.showerror, err), "MethodError: no method matching Returns(::Any, ::Val{N})")
@test startswith(sprint(Base.showerror, err), "MethodError: no method matching for invoke of Returns(::Any, ::Val{N})")
end

0 comments on commit dc4d8a1

Please sign in to comment.