mediawiki-extensions-Scribunto/tests/engines/LuaSandbox/SandboxTests.lua
tstarling b68cae904a More tests and some related bug fixes
* Added tests for the engine classes.
* Added some tests that run under Lua.
* In the chunk names, fixed truncation of module names at 60 bytes
  by using an "=" prefix instead of @.
* Fixed a bug in mw.clone() which was causing the metatable to be set on
  the source table instead of the destination.
* Put restricted setfenv/getfenv in the cloned environment rather than
  the base environment, they work better that way.
* In setfenv(), check for getfenv() == nil, since that's what our own
  restricted getfenv returns.
* Fixed getfenv() handling of numeric arguments: add one where
  appropriate.

Change-Id: I2b356fd65a3fcb348c4e99a3a4267408fb995739
2012-04-19 17:48:20 +10:00

20 lines
338 B
Lua

local test = require( 'Module:CommonTests' )
local sbtest = {}
function sbtest.getTests()
return {
{ 'setfenv1', { error = '%sinvalid level%s' } },
{ 'getfenv1', { error = '%sinvalid level%s' } },
}
end
function sbtest.setfenv1()
setfenv( 2, {} )
end
function sbtest.getfenv1()
assert( getfenv( 2 ) == nil )
end
return sbtest