1
0

Improved resilience of library.lua. Pretty can now run in a sandbox while still providing information about the std functions exposed to it.

This commit is contained in:
Jon Michael Aanes 2017-01-05 13:22:25 +01:00
parent 877c954b78
commit 931d422581
2 changed files with 566 additions and 379 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,26 @@ SUITE:setEnviroment{
--------------------------------------------------------------------------------
SUITE:addTest('library', function ()
SUITE:addTest('no_std_lib', function ()
-- This tests whether one could load the library with an empty env, without
-- an error.
local chunk = loadfile('./library.lua')
setfenv(chunk, {})
local library = chunk()
for func, func_info in pairs(library) do
error(('For some reason %s is defined in the library'):format(func_info.name))
end
end)
SUITE:addTest('a_very_small_part_of_math', function ()
-- This tests whether one could load the library with an empty env, without
-- an error.
local chunk = loadfile('./library.lua')
setfenv(chunk, { math = { abs = math.abs } })
local library = chunk()
assert( library[math.abs], 'Why is math.abs not defined in the library?' )
end)
--------------------------------------------------------------------------------