mirror of
https://github.com/kikito/lua-sandbox.git
synced 2024-12-18 03:04:20 +00:00
more fiddling with string.rep
This commit is contained in:
parent
b22efe1ca8
commit
95069bd456
@ -54,10 +54,12 @@ local function run(f, options)
|
||||
string.rep = nil
|
||||
|
||||
setfenv(f, BASE_ENV)
|
||||
local result = f()
|
||||
local ok, result = pcall(f)
|
||||
|
||||
string.rep = string_rep
|
||||
|
||||
if not ok then error(result) end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
@ -33,6 +33,11 @@ describe('sandbox', function()
|
||||
assert.equal('hellohello', string.rep('hello', 2))
|
||||
end)
|
||||
|
||||
it('restores string.rep even if there is an error', function()
|
||||
assert.has_error(function() sandbox("error('foo')") end)
|
||||
assert.equal('hellohello', string.rep('hello', 2))
|
||||
end)
|
||||
|
||||
|
||||
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user