Skip to content

Commit bee5dd4

Browse files
authored
Merge pull request #56 from tkf/do
Support do blocks
2 parents b9800a3 + b2b2578 commit bee5dd4

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/debug.jl

+6
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ function prepare_caller_capture!(io) # for testing, needs to work on a normal I
354354
callexpr = callexpr.args[1]
355355
elseif callexpr.head == :...
356356
callexpr = callexpr.args[1]
357+
elseif callexpr.head == :do
358+
callexpr = Expr(
359+
:call,
360+
callexpr.args[1].args[1], # function name
361+
callexpr.args[2], # do block (anonymous function)
362+
callexpr.args[1].args[2:end]...) # other arguments
357363
end
358364
# Must be a call or broadcast
359365
((callexpr.head == :call) | (callexpr.head == :.)) || throw(Meta.ParseError("point must be at a call expression, got $callexpr"))

test/runtests.jl

+24
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,30 @@ Base.show(io::IO, ::ErrorsOnShow) = throw(ArgumentError("no show"))
289289
end"""
290290
@test Rebugger.getstored(string(uuid)) == (max, ([1,5], [2,-3]), typeof(max))
291291
Core.eval(Main, Meta.parse(cmd)) == [2,5]
292+
293+
# Step in to a do block
294+
str = "RebuggerTesting.calldo()"
295+
uuidref, cmd = run_stepin(str, str)
296+
uuid1 = uuidextractor(cmd)
297+
@test uuid1 == uuidref
298+
@test cmd == """
299+
@eval Main.RebuggerTesting let () = Main.Rebugger.getstored("$uuid1")
300+
begin
301+
apply(2, 3, 4) do x, y, z
302+
snoop3(x, y, z)
303+
end
304+
end
305+
end"""
306+
uuidref, cmd = run_stepin(cmd, "apply")
307+
uuid1 = uuidextractor(cmd)
308+
@test uuid1 == uuidref
309+
@test cmd == """
310+
@eval Main.RebuggerTesting let (f, args) = Main.Rebugger.getstored("$uuid1")
311+
begin
312+
kwvarargs(f)
313+
f(args...)
314+
end
315+
end"""
292316
end
293317

294318
@testset "Capture stacktrace" begin

test/testmodule.jl

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ const hv_test = HasValue(11.1)
2727
@noinline kwfuncmiddle(x::T, y::Integer=1; kw1="hello", kwargs...) where T = kwfuncerr(y)
2828
@inline kwfunctop(x; kwargs...) = kwfuncmiddle(x, 2; kwargs...)
2929

30+
function apply(f, args...)
31+
kwvarargs(f)
32+
f(args...)
33+
end
34+
35+
calldo() = apply(2, 3, 4) do x, y, z
36+
snoop3(x, y, z)
37+
end
38+
3039
end
3140

3241
module RBT2

0 commit comments

Comments
 (0)