Skip to content

Commit

Permalink
more tests, remove named sandboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi committed Jun 25, 2024
1 parent 118a11b commit a0281e7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/CodeEvaluation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ using IOCapture: IOCapture
using REPL: REPL

include("sandbox.jl")
include("namedsandboxes.jl")

end
22 changes: 0 additions & 22 deletions src/namedsandboxes.jl

This file was deleted.

37 changes: 27 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ using Test
end
end

@testset "NamedSandboxes" begin
sandboxes = CodeEvaluation.NamedSandboxes(@__DIR__, "testsandbox")
sb1 = get!(sandboxes, "foo")
sb2 = get!(sandboxes, "bar")
sb3 = get!(sandboxes, "foo")
@test sb1.m !== sb2.m
@test sb1.m === sb3.m
@test sb2.m !== sb3.m
end

@testset "evaluate!" begin
let sb = CodeEvaluation.Sandbox(:foo; workingdirectory=@__DIR__)
write(sb, "2 + 2")
Expand Down Expand Up @@ -93,5 +83,32 @@ using Test
@test r.value[] === 5
@test r.output === "4"
end

let sb = CodeEvaluation.Sandbox(:foo; workingdirectory=@__DIR__)
r = CodeEvaluation.evaluate!(sb, """error("x")""")
@test r isa CodeEvaluation.Result
@test r.sandbox === sb
@test r.value isa CodeEvaluation.ExceptionValue
@test r.value[] isa ErrorException
@test r.value[].msg == "x"
@test r.output === ""
end

let sb = CodeEvaluation.Sandbox(:foo; workingdirectory=@__DIR__)
r = CodeEvaluation.evaluate!(
sb,
"""
print("x")
error("x")
print("y")
"""
)
@test r isa CodeEvaluation.Result
@test r.sandbox === sb
@test r.value isa CodeEvaluation.ExceptionValue
@test r.value[] isa ErrorException
@test r.value[].msg == "x"
@test r.output === "x"
end
end
end

0 comments on commit a0281e7

Please sign in to comment.