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:
parent
877c954b78
commit
931d422581
929
library.lua
929
library.lua
File diff suppressed because it is too large
Load Diff
|
@ -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)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user