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
93 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 | ||
|
||
fe(x::Float64, s::AbstractString...) = true | ||
ge(x::Int32, args...) = true | ||
ge(x::Int32, y::Float64 ,args...) = true | ||
ge(x::Int32, y::Float64) = true | ||
ge{T<:Real}(x::T, y::T, z::T) = true | ||
|
||
buf = IOBuffer() | ||
Base.show_method_candidates(buf, Base.MethodError(fe,(1, 1, ""))) | ||
no_color = "\nClosest candidates are:\n fe(::Float64, ::AbstractString...)\n" | ||
test_have_color(buf, | ||
"\e[0m\nClosest candidates are:\n fe(\e[1m\e[31m::Float64\e[0m, \e[1m\e[31m::AbstractString...\e[0m)\n\e[0m", | ||
no_color) | ||
|
||
Base.show_method_candidates(buf, Base.MethodError(fe,(1, "", ""))) | ||
test_have_color(buf, | ||
"\e[0m\nClosest candidates are:\n fe(\e[1m\e[31m::Float64\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 fe(::Float64, ::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, "", "") | ||
|
||
|
||
Base.show_method_candidates(buf, Base.MethodError(ge,(1., 1., 2))) | ||
color = "\e[0m\nClosest candidates are:\n ge(\e[1m\e[31m::Int32\e[0m, ::Float64, ::Any...)\n ge(\e[1m\e[31m::Int32\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 = "\nClosest candidates are:\n ge(::Int32, ::Float64, ::Any...)\n ge(::Int32, ::Any...)\n ge{T<:Real}(::T<:Real, ::T<:Real, ::T<:Real)\n ...\n" | ||
test_have_color(buf, color, no_color) |
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