Skip to content

Commit

Permalink
improve "top-level statement selection" testset
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jul 17, 2023
1 parent 71867a0 commit eee264b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/toplevel/test_virtualprocess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1680,8 +1680,7 @@ end

@testset "top-level statement selection" begin
# simplest example
let
# global function
let # global function
vmod, res = @analyze_toplevel2 begin
foo() = return # should be concretized
end
Expand Down Expand Up @@ -1709,20 +1708,28 @@ end
end
slice = JET.select_statements(src)

found_w = found_sum = found_product = found_write = false
for (i, stmt) in enumerate(src.code)
if JET.isexpr(stmt, :(=))
lhs, rhs = stmt.args
if isa(lhs, Core.SlotNumber)
if src.slotnames[lhs.id] === :w || src.slotnames[lhs.id] === :sum
if src.slotnames[lhs.id] === :w
found_w = true
@test slice[i]
elseif src.slotnames[lhs.id] === :sum
found_sum = true
@test slice[i]
elseif src.slotnames[lhs.id] === :product
found_product = true
@test !slice[i]
end
end
elseif JET.@capture(stmt, write(x_))
found_write = true
@test !slice[i]
end
end
@test found_w; @test found_sum; @test found_product; @test found_write
end

@testset "captured variables" begin
Expand Down

0 comments on commit eee264b

Please sign in to comment.