howl.aux.Sandbox(env, options)

allows running a function with a specified environment

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

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 what: -> 'bar!'
assert.equal 'bar!', box -> return what!

allows global access by default

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

disallows global access if options.no_globals is set

box = Sandbox nil, 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 nil, 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 box.exports.foo, 'bar'