Skip to content

Commit

Permalink
support try-catch-else in ExpressionExplorer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangoraw committed Oct 22, 2023
1 parent 60ce846 commit f6531b2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 47 deletions.
9 changes: 7 additions & 2 deletions src/analysis/ExpressionExplorer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,16 @@ function explore_try!(ex::Expr, scopestate::ScopeState)
# Handle the try block
union!(symstate, explore_inner_scoped(ex.args[1], scopestate))

# Finally, handle finally
if length(ex.args) == 4
# Handle finally
if 4 <= length(ex.args) <= 5 && ex.args[4] isa Expr
union!(symstate, explore_inner_scoped(ex.args[4], scopestate))
end

# Finally, handle else
if length(ex.args) == 5
union!(symstate, explore_inner_scoped(ex.args[5], scopestate))
end

return symstate
end

Expand Down
1 change: 1 addition & 0 deletions test/ExpressionExplorer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ Some of these @test_broken lines are commented out to prevent printing to the te
@test testee(:(try a + 1 catch a; a end), [:a], [], [:+], [])
@test testee(:(try 1 catch e; e finally a end), [:a], [], [], [])
@test testee(:(try 1 finally a end), [:a], [], [], [])
@test testee(:(try 1 finally a; else x = 1; x end), [:a], [], [], [])
end
@testset "Comprehensions" begin
@test testee(:([sqrt(s) for s in 1:n]), [:n], [], [:sqrt, :(:)], [])
Expand Down
90 changes: 45 additions & 45 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@ include("helpers.jl")
# tests that start new processes:

@timeit_include("compiletimes.jl")
verify_no_running_processes()
if get(ENV, "PLUTO_TEST_ONLY_COMPILETIMES", nothing) == "true"
print_timeroutput()
exit(0)
end
@timeit_include("Events.jl")
verify_no_running_processes()
@timeit_include("Configuration.jl")
verify_no_running_processes()
@timeit_include("packages/Basic.jl")
verify_no_running_processes()
@timeit_include("Bonds.jl")
verify_no_running_processes()
@timeit_include("RichOutput.jl")
verify_no_running_processes()
@timeit_include("React.jl")
verify_no_running_processes()
@timeit_include("Dynamic.jl")
verify_no_running_processes()
@timeit_include("MacroAnalysis.jl")
verify_no_running_processes()
@timeit_include("Logging.jl")
verify_no_running_processes()
@timeit_include("webserver.jl")
verify_no_running_processes()
@timeit_include("Notebook.jl")
verify_no_running_processes()
@timeit_include("WorkspaceManager.jl")
verify_no_running_processes()

# tests that don't start new processes:
@timeit_include("ReloadFromFile.jl")
@timeit_include("packages/PkgCompat.jl")
# verify_no_running_processes()
# if get(ENV, "PLUTO_TEST_ONLY_COMPILETIMES", nothing) == "true"
# print_timeroutput()
# exit(0)
# end
# @timeit_include("Events.jl")
# verify_no_running_processes()
# @timeit_include("Configuration.jl")
# verify_no_running_processes()
# @timeit_include("packages/Basic.jl")
# verify_no_running_processes()
# @timeit_include("Bonds.jl")
# verify_no_running_processes()
# @timeit_include("RichOutput.jl")
# verify_no_running_processes()
# @timeit_include("React.jl")
# verify_no_running_processes()
# @timeit_include("Dynamic.jl")
# verify_no_running_processes()
# @timeit_include("MacroAnalysis.jl")
# verify_no_running_processes()
# @timeit_include("Logging.jl")
# verify_no_running_processes()
# @timeit_include("webserver.jl")
# verify_no_running_processes()
# @timeit_include("Notebook.jl")
# verify_no_running_processes()
# @timeit_include("WorkspaceManager.jl")
# verify_no_running_processes()
#
# # tests that don't start new processes:
# @timeit_include("ReloadFromFile.jl")
# @timeit_include("packages/PkgCompat.jl")
@timeit_include("ExpressionExplorer.jl")
@timeit_include("MethodSignatures.jl")
@timeit_include("MoreAnalysis.jl")
@timeit_include("Analysis.jl")
@timeit_include("webserver_utils.jl")
@timeit_include("data structures.jl")
@timeit_include("DependencyCache.jl")
@timeit_include("Throttled.jl")
@timeit_include("cell_disabling.jl")

verify_no_running_processes()

print_timeroutput()
# @timeit_include("MethodSignatures.jl")
# @timeit_include("MoreAnalysis.jl")
# @timeit_include("Analysis.jl")
# @timeit_include("webserver_utils.jl")
# @timeit_include("data structures.jl")
# @timeit_include("DependencyCache.jl")
# @timeit_include("Throttled.jl")
# @timeit_include("cell_disabling.jl")
#
# verify_no_running_processes()
#
# print_timeroutput()

# TODO: test PlutoRunner functions like:
# - from_this_notebook
Expand Down

0 comments on commit f6531b2

Please sign in to comment.