From 688e8431f8a24bc0e5c43734d40298c0f145921e Mon Sep 17 00:00:00 2001 From: KristofferC Date: Thu, 4 Apr 2019 14:51:10 +0200 Subject: [PATCH] fix off by one in definition --- src/CodeTracking.jl | 1 + test/runtests.jl | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/CodeTracking.jl b/src/CodeTracking.jl index 6fc8991..844047d 100644 --- a/src/CodeTracking.jl +++ b/src/CodeTracking.jl @@ -198,6 +198,7 @@ function definition(::Type{String}, method::Method) istart = findnext(eol, src, istart) + 1 end ex, iend = Meta.parse(src, istart) + iend = prevind(src, iend) if isfuncexpr(ex) iend = min(iend, lastindex(src)) return strip(src[istart:iend], '\n'), line diff --git a/test/runtests.jl b/test/runtests.jl index 495d991..204b089 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -114,3 +114,17 @@ end @test !isempty(signatures_at("script.jl", 9)) end end + +(a_34)(x::T, y::T) where {T<:Integer} = no_op_err("&", T) +(b_34)(x::T, y::T) where {T<:Integer} = no_op_err("|", T) +c_34(x::T, y::T) where {T<:Integer} = no_op_err("xor", T) + +(d_34)(x::T, y::T) where {T<:Number} = x === y +(e_34)(x::T, y::T) where {T<:Real} = no_op_err("<" , T) +(f_34)(x::T, y::T) where {T<:Real} = no_op_err("<=", T) +l = @__LINE__ +@testset "#34 last character" begin + def, line = definition(String, @which d_34(1, 2)) + @test line == l - 3 + @test def == "(d_34)(x::T, y::T) where {T<:Number} = x === y" +end \ No newline at end of file