@@ -46,14 +46,38 @@ const JL = JuliaLowering
4646 @test isdefined (test_mod. M, :x )
4747
4848 # Tricky cases with symbols
49- out = jeval (""" module M
49+ out = jeval (""" module M2
5050 Base.@constprop :aggressive function f(x); x; end
5151 const what = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), Core.nothing)
5252 end""" )
5353 @test out isa Module
54- @test isdefined (test_mod, :M )
55- @test isdefined (test_mod. M, :f )
56- @test isdefined (test_mod. M, :what )
54+ @test isdefined (test_mod, :M2 )
55+ @test isdefined (test_mod. M2, :f )
56+ @test isdefined (test_mod. M2, :what )
57+
58+ out = jeval (""" "docstring" module M3 end """ )
59+ @test out isa Module
60+ @test isdefined (test_mod, :M3 )
61+
62+ # Macros may produce toplevel expressions. Note that julia handles
63+ # this case badly (macro expansion replaces M5_inner with a
64+ # globalref) and we handle esc(:M5_inner) badly
65+ out = jeval (""" module M5
66+ macro newmod()
67+ return quote
68+ let a = 1
69+ $(Expr (:toplevel ,
70+ Expr (:module , true , :M5_inner ,
71+ Expr (:block , :(global asdf = 1 )))))
72+ end
73+ end
74+ end
75+ @newmod()
76+ end""" )
77+ @test out isa Module
78+ @test isdefined (test_mod, :M5 )
79+ @test isdefined (test_mod. M5, :M5_inner )
80+ @test isdefined (test_mod. M5. M5_inner, :asdf )
5781
5882 # TODO : broken, commented to prevent error logging
5983 # @test jeval("Base.@propagate_inbounds @inline meta_double_quote_issue(x) = x") isa Function
0 commit comments