Skip to content

Commit 1726524

Browse files
KristofferCtimholy
authored andcommitted
fix off by one in definition (#35)
1 parent 42c1103 commit 1726524

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/CodeTracking.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ function definition(::Type{String}, method::Method)
198198
istart = findnext(eol, src, istart) + 1
199199
end
200200
ex, iend = Meta.parse(src, istart)
201+
iend = prevind(src, iend)
201202
if isfuncexpr(ex)
202203
iend = min(iend, lastindex(src))
203204
return strip(src[istart:iend], '\n'), line

test/runtests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,17 @@ end
114114
@test !isempty(signatures_at("script.jl", 9))
115115
end
116116
end
117+
118+
(a_34)(x::T, y::T) where {T<:Integer} = no_op_err("&", T)
119+
(b_34)(x::T, y::T) where {T<:Integer} = no_op_err("|", T)
120+
c_34(x::T, y::T) where {T<:Integer} = no_op_err("xor", T)
121+
122+
(d_34)(x::T, y::T) where {T<:Number} = x === y
123+
(e_34)(x::T, y::T) where {T<:Real} = no_op_err("<" , T)
124+
(f_34)(x::T, y::T) where {T<:Real} = no_op_err("<=", T)
125+
l = @__LINE__
126+
@testset "#34 last character" begin
127+
def, line = definition(String, @which d_34(1, 2))
128+
@test line == l - 3
129+
@test def == "(d_34)(x::T, y::T) where {T<:Number} = x === y"
130+
end

0 commit comments

Comments
 (0)