Skip to content

Commit b3bc13e

Browse files
committed
Add some more debug tests
1 parent c5c3ec8 commit b3bc13e

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

test/debug.jl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using JuliaInterpreter, Test
2-
using JuliaInterpreter: enter_call, enter_call_expr, get_return
2+
using JuliaInterpreter: enter_call, enter_call_expr, get_return, @lookup
3+
using Base.Meta: isexpr
34

45
function step_through(frame)
56
r = root(frame)
@@ -21,6 +22,8 @@ macro insert_some_calls()
2122
end)
2223
end
2324

25+
struct B{T} end
26+
2427
# @testset "Debug" begin
2528
@testset "Basics" begin
2629
frame = enter_call(map, x->2x, 1:10)
@@ -68,7 +71,7 @@ end
6871
@test isa(pc, BreakpointRef)
6972
@test JuliaInterpreter.scopeof(f).name == :generatedfoo
7073
stmt = JuliaInterpreter.pc_expr(f)
71-
@test stmt.head == :return && JuliaInterpreter.@lookup(f, stmt.args[1]) === 1
74+
@test stmt.head == :return && @lookup(f, stmt.args[1]) === 1
7275
f2, pc = debug_command(f, "finish")
7376
@test JuliaInterpreter.scopeof(f2).name == :callgenerated
7477
# Now finish the regular function
@@ -126,6 +129,22 @@ end
126129
@test debug_command(fr, "finish") === nothing
127130
@test frame.callee === nothing
128131
@test get_return(frame) == 3
132+
133+
frame = JuliaInterpreter.enter_call(f, 2; b = 4)
134+
fr = JuliaInterpreter.maybe_step_through_wrapper!(frame)
135+
fr, pc = debug_command(fr, "nc")
136+
fr, pc = debug_command(fr, "nc")
137+
@test get_return(frame) == 6
138+
end
139+
140+
@testset "Quoting" begin
141+
# Test that symbols don't get an extra QuoteNode
142+
f_symbol() = :limit => true
143+
frame = JuliaInterpreter.enter_call(f_symbol)
144+
fr, pc = debug_command(frame, "s")
145+
fr, pc = debug_command(fr, "finish")
146+
@test debug_command(fr, "finish") === nothing
147+
@test get_return(frame) == f_symbol()
129148
end
130149

131150
@testset "Varargs" begin
@@ -145,6 +164,15 @@ end
145164
@test get_return(frame) === 2
146165
end
147166

167+
@testset "ASTI#17" begin
168+
function (::B)(y)
169+
x = 42*y
170+
return x + y
171+
end
172+
B_inst = B{Int}()
173+
step_through(JuliaInterpreter.enter_call(B_inst, 10)) == B_inst(10)
174+
end
175+
148176
@testset "Exceptions" begin
149177
# Don't break on caught exceptions
150178
err_caught = Any[nothing]

0 commit comments

Comments
 (0)