1
1
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
3
4
4
5
function step_through (frame)
5
6
r = root (frame)
@@ -21,6 +22,8 @@ macro insert_some_calls()
21
22
end )
22
23
end
23
24
25
+ struct B{T} end
26
+
24
27
# @testset "Debug" begin
25
28
@testset " Basics" begin
26
29
frame = enter_call (map, x-> 2 x, 1 : 10 )
68
71
@test isa (pc, BreakpointRef)
69
72
@test JuliaInterpreter. scopeof (f). name == :generatedfoo
70
73
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
72
75
f2, pc = debug_command (f, " finish" )
73
76
@test JuliaInterpreter. scopeof (f2). name == :callgenerated
74
77
# Now finish the regular function
126
129
@test debug_command (fr, " finish" ) === nothing
127
130
@test frame. callee === nothing
128
131
@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 ()
129
148
end
130
149
131
150
@testset " Varargs" begin
145
164
@test get_return (frame) === 2
146
165
end
147
166
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
+
148
176
@testset " Exceptions" begin
149
177
# Don't break on caught exceptions
150
178
err_caught = Any[nothing ]
0 commit comments