@@ -104,26 +104,6 @@ struct B{T} end
104104 @test debug_command (frame, " n" ) === nothing
105105 end
106106
107- @testset " Macros" begin
108- # Work around the fact that we can't detect macro expansions if the macro
109- # is defined in the same file
110- include_string (Main, """
111- function test_macro()
112- a = sin(5)
113- b = asin(a)
114- @insert_some_calls
115- z
116- end
117- """ ," file.jl" )
118- frame = JuliaInterpreter. enter_call_expr (:($ (test_macro)()))
119- f, pc = debug_command (frame, " n" ) # a is set
120- f, pc = debug_command (f, " n" ) # b is set
121- f, pc = debug_command (f, " n" ) # x is set
122- f, pc = debug_command (f, " n" ) # y is set
123- f, pc = debug_command (f, " n" ) # z is set
124- @test debug_command (f, " n" ) === nothing # return
125- end
126-
127107 @testset " Keyword arguments" begin
128108 f (x; b = 1 ) = x+ b
129109 g () = f (1 ; b = 2 )
@@ -144,6 +124,55 @@ struct B{T} end
144124 @test get_return (frame) == 6
145125 end
146126
127+ @testset " Optional + keyword wrappers" begin
128+ opkw (a, b= 1 ; c= 2 , d= 3 ) = 1
129+ callopkw1 () = opkw (0 )
130+ callopkw2 () = opkw (0 , - 1 )
131+ callopkw3 () = opkw (0 ; c= - 2 )
132+ callopkw4 () = opkw (0 , - 1 ; c= - 2 )
133+ callopkw5 () = opkw (0 ; c= - 2 , d= - 3 )
134+ callopkw6 () = opkw (0 , - 1 ; c= - 2 , d= - 3 )
135+ scopes = Method[]
136+ for f in (callopkw1, callopkw2, callopkw3, callopkw4, callopkw5, callopkw6)
137+ frame = fr = JuliaInterpreter. enter_call (f)
138+ pc = fr. pc
139+ while pc <= JuliaInterpreter. nstatements (fr. framecode) - 2
140+ fr, pc = debug_command (fr, " se" )
141+ end
142+ fr, pc = debug_command (frame, " si" )
143+ @test stacklength (frame) == 2
144+ frame = fr = JuliaInterpreter. enter_call (f)
145+ pc = fr. pc
146+ while pc <= JuliaInterpreter. nstatements (fr. framecode) - 2
147+ fr, pc = debug_command (fr, " se" )
148+ end
149+ fr, pc = debug_command (frame, " s" )
150+ @test stacklength (frame) > 2
151+ push! (scopes, JuliaInterpreter. scopeof (fr))
152+ end
153+ @test length (unique (scopes)) == 1 # all get to the body method
154+ end
155+
156+ @testset " Macros" begin
157+ # Work around the fact that we can't detect macro expansions if the macro
158+ # is defined in the same file
159+ include_string (Main, """
160+ function test_macro()
161+ a = sin(5)
162+ b = asin(a)
163+ @insert_some_calls
164+ z
165+ end
166+ """ ," file.jl" )
167+ frame = JuliaInterpreter. enter_call_expr (:($ (test_macro)()))
168+ f, pc = debug_command (frame, " n" ) # a is set
169+ f, pc = debug_command (f, " n" ) # b is set
170+ f, pc = debug_command (f, " n" ) # x is set
171+ f, pc = debug_command (f, " n" ) # y is set
172+ f, pc = debug_command (f, " n" ) # z is set
173+ @test debug_command (f, " n" ) === nothing # return
174+ end
175+
147176 @testset " Quoting" begin
148177 # Test that symbols don't get an extra QuoteNode
149178 f_symbol () = :limit => true
0 commit comments