Skip to content

Commit 5e8957c

Browse files
authored
simplify test_virtualprocess.jl (#197)
1 parent 5708d11 commit 5e8957c

File tree

2 files changed

+61
-75
lines changed

2 files changed

+61
-75
lines changed

test/interactive_utils.jl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ macro fixturedef(ex)
5151
end
5252

5353
"""
54-
@analyze_toplevel [jetconfigs...] ex
54+
@analyze_toplevel [jetconfigs...] ex -> JET.VirtualProcessResult
5555
5656
Enters JET analysis from toplevel expression `ex`, and returns the analysis result.
5757
"""
@@ -63,6 +63,29 @@ macro analyze_toplevel(xs...)
6363
return _analyze_toplevel(ex, __source__, jetconfigs)
6464
end
6565

66+
"""
67+
@analyze_toplevel2 [jetconfigs...] ex -> (Module, JET.VirtualProcessResult)
68+
69+
Works similarly to `@analyze_toplevel`, but also creates a virtual module beforehand and
70+
returns that as well after the whole analysis for the later inspection.
71+
"""
72+
macro analyze_toplevel2(xs...)
73+
jetconfigs = filter(iskwarg, xs)
74+
xs′ = filter(!iskwarg, xs)
75+
@assert length(xs′) == 1
76+
ex = first(xs′)
77+
78+
vmod = gensym(:vmod)
79+
jetconfigs = (:(context = $vmod), jetconfigs...,)
80+
jetconfigs = (:(virtualize = false), jetconfigs...,)
81+
ex2 = _analyze_toplevel(ex, __source__, jetconfigs)
82+
return :(let
83+
$(esc(vmod)) = $gen_virtual_module()
84+
ret2 = $ex2
85+
$(esc(vmod)), ret2
86+
end)
87+
end
88+
6689
iskwarg(@nospecialize(x)) = isexpr(x, :(=))
6790

6891
function _analyze_toplevel(ex, lnn, jetconfigs)

0 commit comments

Comments
 (0)