forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added so JuliaLang#7714 also takes care of args... when considering a…
… match and removed the requirement of equal lengths of args. The match also takes into account that parametric methods args needs to have the same type for one tvar using typeintersect. There is also added test of `show_method_candidates`.
- Loading branch information
Showing
3 changed files
with
92 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function test_have_color(buf, color, no_color) | ||
if Base.have_color | ||
@test takebuf_string(buf) == color | ||
else | ||
@test takebuf_string(buf) == no_color | ||
end | ||
end | ||
let | ||
fe(x::Int, s::AbstractString...) = pass | ||
buf = IOBuffer() | ||
Base.show_method_candidates(buf, Base.MethodError(fe,(1.,1,""))) | ||
no_color = "Closest candidates are:\n f(::Int64, ::AbstractString...)" | ||
test_have_color(buf, | ||
"\e[0m\nClosest candidates are:\n fe(\e[1m\e[31m::Int64\e[0m, \e[1m\e[31m::AbstractString...\e[0m)\n\e[0m", | ||
no_color) | ||
|
||
Base.show_method_candidates(buf, Base.MethodError(f,(1.,"",""))) | ||
test_have_color(buf, | ||
"\e[0m\nClosest candidates are:\n fe(\e[1m\e[31m::Int64\e[0m, ::AbstractString...)\n\e[0m", | ||
no_color) | ||
|
||
# should match | ||
Base.show_method_candidates(buf, Base.MethodError(fe,(1,"",""))) | ||
test_have_color(buf, | ||
"\e[0m\nClosest candidates are:\n f(::Int64, ::AbstractString...)\n\e[0m", | ||
no_color) | ||
|
||
# Have no matches so should return empty | ||
Base.show_method_candidates(buf, Base.MethodError(fe,(1.,1,1))) | ||
test_have_color(buf, "", "") | ||
|
||
ge(x::Int, args...) = pass | ||
ge(x::Int, y::Float64 ,args...) = pass | ||
ge(x::Int, y::Float64) = pass | ||
ge{T<:Real}(x::T, y::T, z::T) = pass | ||
Base.show_method_candidates(buf, Base.MethodError(g,(1.,1.,2))) | ||
color = "\e[0m\nClosest candidates are:\n ge(\e[1m\e[31m::Int64\e[0m, ::Float64, ::Any...)\n ge(\e[1m\e[31m::Int64\e[0m, ::Any...)\n ge{T<:Real}(::T<:Real, ::T<:Real, \e[1m\e[31m::T<:Real\e[0m)\n ...\n\e[0m" | ||
no_color = no_color = "Closest candidates are:\n ge(::Int64, ::Float64, ::Any...)\n ge(::Int64, ::Any...)\n ge{T<:Real}(::T<:Real, ::T<:Real, ::T<:Real)\n ..." | ||
test_have_color(buf, color, no_color) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters