allows running a function with a specified environment

box = Sandbox env: {from_env: -> 'bar!'}
assert.equal 'bar!', box -> from_env!

allows passing parameters to the function

box = Sandbox!
f = (...) -> return ...
assert.equal 'bar!', box(f, 'bar!')

.put allows modifiying the environment

box = Sandbox!
box\put from_env: -> 'bar!'
assert.equal 'bar!', box -> from_env!

allows global access by default

box = Sandbox!
assert.equal table, box -> return table

disallows global access if options.no_globals is set

box = Sandbox no_globals: true
assert.is_nil box -> return table

(when options.no_implicit_globals is set)

raises an error upon implicit global writes

box = Sandbox no_implicit_globals: true
renegade = -> export frob = 'bar!'
assert.raises 'implicit global', -> box renegade

(when options.no_implicit_globals is not set)

collects exports into .exports

box = Sandbox!
box -> export foo = 'bar'
assert.equal, 'bar'