10 use MediaWikiCoversValidator;
11 use PHPUnit4And6Compat;
14 'memoryLimit' => 50000000,
16 'allowEnvFuncs' =>
true,
21 'memoryLimit' => 50000000,
23 'allowEnvFuncs' =>
true,
33 $engine =
new $class ( [
'parser' => $parser ] + $opts );
34 $parser->scribunto_engine = $engine;
35 $engine->setTitle( $parser->getTitle() );
36 $engine->getInterpreter();
44 $this->engines[
'LuaSandbox'] = $this->
makeEngine(
45 'Scribunto_LuaSandboxEngine', $this->sandboxOpts
48 $this->markTestSkipped(
"LuaSandbox interpreter not available" );
53 $this->engines[
'LuaStandalone'] = $this->
makeEngine(
54 'Scribunto_LuaStandaloneEngine', $this->standaloneOpts
57 $this->markTestSkipped(
"LuaStandalone interpreter not available" );
63 foreach ( $this->engines as $engine ) {
71 static $script = <<<LUA
73 function xxxGetTable( t )
79 for k, v in pairs( t )
do
80 if k ~=
'_G' and
string.sub( k, 1, 3 ) ~=
'xxx' then
81 if type( v ) ==
'table' then
82 ret[k] = xxxGetTable( v )
83 elseif type( v ) ==
'string'
84 or type( v ) ==
'number'
85 or type( v ) ==
'boolean'
96 return xxxGetTable( _G )
98 $func = $engine->getInterpreter()->loadString( $script,
'script' );
99 return $engine->getInterpreter()->callFunction( $func );
104 $firstEngine = reset( $this->engines );
105 $firstName = key( $this->engines );
109 foreach ( $this->engines as $secondName => $secondEngine ) {
110 if ( $secondName !== $firstName ) {
112 $this->assertEquals( $firstEnv, $secondEnv,
113 "Environments for $firstName and $secondName are not equivalent" );