From 7aba3f57bcd370c7bda2a3df4ba6cecf3553df33 Mon Sep 17 00:00:00 2001 From: Daniel Matz Date: Tue, 1 Nov 2016 12:23:49 -0500 Subject: [PATCH] Add module name to method show output (#19162) * Add the method's module name to the show output * Update tests that involve showing a method --- base/methodshow.jl | 2 +- test/ambiguous.jl | 4 ++-- test/reflection.jl | 2 +- test/replutil.jl | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/base/methodshow.jl b/base/methodshow.jl index 3e86088b17e99..f00d8aa354760 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -110,7 +110,7 @@ function show(io::IO, m::Method; kwtype::Nullable{DataType}=Nullable{DataType}() join(io, kwargs, ", ", ", ") end end - print(io, ")") + print(io, ") in ", m.module) if line > 0 print(io, " at ", file, ":", line) end diff --git a/test/ambiguous.jl b/test/ambiguous.jl index cf0d625e90ee0..0ea47c6fb8d45 100644 --- a/test/ambiguous.jl +++ b/test/ambiguous.jl @@ -52,8 +52,8 @@ let err = try io = IOBuffer() Base.showerror(io, err) lines = split(takebuf_string(io), '\n') - ambig_checkline(str) = startswith(str, " ambig(x, y::Integer) at") || - startswith(str, " ambig(x::Integer, y) at") + ambig_checkline(str) = startswith(str, " ambig(x, y::Integer) in Main at") || + startswith(str, " ambig(x::Integer, y) in Main at") @test ambig_checkline(lines[2]) @test ambig_checkline(lines[3]) end diff --git a/test/reflection.jl b/test/reflection.jl index e2ff815de12ba..56ac13c73c11d 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -442,7 +442,7 @@ let li = typeof(getfield).name.mt.cache.func::Core.MethodInstance, mmime = stringmime("text/plain", li.def) @test lrepr == lmime == "MethodInstance for getfield(...)" - @test mrepr == mmime == "getfield(...)" + @test mrepr == mmime == "getfield(...) in Core" end diff --git a/test/replutil.jl b/test/replutil.jl index 9fbb928a577e0..c427885845213 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -363,15 +363,15 @@ let err_str, sp = Base.source_path() sn = basename(sp) - @test sprint(show, which(Symbol, Tuple{})) == "Symbol() at $sp:$(method_defs_lineno + 0)" - @test sprint(show, which(:a, Tuple{})) == "(::Symbol)() at $sp:$(method_defs_lineno + 1)" - @test sprint(show, which(EightBitType, Tuple{})) == "EightBitType() at $sp:$(method_defs_lineno + 2)" - @test sprint(show, which(reinterpret(EightBitType, 0x54), Tuple{})) == "(::EightBitType)() at $sp:$(method_defs_lineno + 3)" - @test sprint(show, which(EightBitTypeT, Tuple{})) == "(::Type{EightBitTypeT})() at $sp:$(method_defs_lineno + 4)" - @test sprint(show, which(EightBitTypeT{Int32}, Tuple{})) == "(::Type{EightBitTypeT{T}}){T}() at $sp:$(method_defs_lineno + 5)" - @test sprint(show, which(reinterpret(EightBitTypeT{Int32}, 0x54), Tuple{})) == "(::EightBitTypeT)() at $sp:$(method_defs_lineno + 6)" - @test startswith(sprint(show, which(getfield(Base, Symbol("@doc")), Tuple{Vararg{Any}})), "@doc(x...) at boot.jl:") - @test startswith(sprint(show, which(FunctionLike(), Tuple{})), "(::FunctionLike)() at $sp:$(method_defs_lineno + 7)") + @test sprint(show, which(Symbol, Tuple{})) == "Symbol() in Main at $sp:$(method_defs_lineno + 0)" + @test sprint(show, which(:a, Tuple{})) == "(::Symbol)() in Main at $sp:$(method_defs_lineno + 1)" + @test sprint(show, which(EightBitType, Tuple{})) == "EightBitType() in Main at $sp:$(method_defs_lineno + 2)" + @test sprint(show, which(reinterpret(EightBitType, 0x54), Tuple{})) == "(::EightBitType)() in Main at $sp:$(method_defs_lineno + 3)" + @test sprint(show, which(EightBitTypeT, Tuple{})) == "(::Type{EightBitTypeT})() in Main at $sp:$(method_defs_lineno + 4)" + @test sprint(show, which(EightBitTypeT{Int32}, Tuple{})) == "(::Type{EightBitTypeT{T}}){T}() in Main at $sp:$(method_defs_lineno + 5)" + @test sprint(show, which(reinterpret(EightBitTypeT{Int32}, 0x54), Tuple{})) == "(::EightBitTypeT)() in Main at $sp:$(method_defs_lineno + 6)" + @test startswith(sprint(show, which(getfield(Base, Symbol("@doc")), Tuple{Vararg{Any}})), "@doc(x...) in Core at boot.jl:") + @test startswith(sprint(show, which(FunctionLike(), Tuple{})), "(::FunctionLike)() in Main at $sp:$(method_defs_lineno + 7)") @test stringmime("text/plain", FunctionLike()) == "(::FunctionLike) (generic function with 1 method)" @test stringmime("text/plain", Core.arraysize) == "arraysize (built-in function)"