mirror of
https://github.com/TangentFoxy/lua-sandbox.git
synced 2025-07-28 11:02:21 +00:00
feat(sandbox) add load mode to string functions
This commit is contained in:
committed by
Enrique García Cota
parent
ddbc7e12cc
commit
8974b8869c
@@ -13,6 +13,16 @@ describe('sandbox.run', function()
|
||||
assert.equal(r, 'hello')
|
||||
end)
|
||||
|
||||
it('can run bytecode strings by default', function()
|
||||
local fn = function() end
|
||||
assert.has_no.error(function() sandbox.run(string.dump(fn)) end)
|
||||
end)
|
||||
|
||||
it('can\'t run bytecode strings if given a \'t\' mode option', function()
|
||||
local fn = function() end
|
||||
assert.error(function() sandbox.run(string.dump(fn), { mode = 't' }) end)
|
||||
end)
|
||||
|
||||
it('has access to safe methods', function()
|
||||
assert.equal(10, sandbox.run("return tonumber('10')"))
|
||||
assert.equal('HELLO', sandbox.run("return string.upper('hello')"))
|
||||
|
Reference in New Issue
Block a user