60 $startTime = microtime(
true );
61 if ( php_uname(
's' ) !==
'Linux' ) {
62 $this->markTestSkipped(
"getStatus() not supported on platforms other than Linux" );
66 $engine = TestingAccessWrapper::newFromObject( $interpreter->engine );
67 $status = $interpreter->getStatus();
68 $pid = $status[
'pid'];
69 $this->assertInternalType(
'integer', $status[
'pid'] );
70 $initialVsize = $this->
getVsize( $pid );
71 $this->assertGreaterThan( 0, $initialVsize,
'Initial vsize' );
75 while ( microtime(
true ) - $startTime < 1 ) {
76 $interpreter->callFunction( $chunk, 100 );
78 $status = $interpreter->getStatus();
80 $time = $status[
'time'] / $engine->getClockTick();
81 $this->assertGreaterThan( 0.1, $time,
'getStatus() time usage' );
82 $this->assertLessThan( 1.5, $time,
'getStatus() time usage' );
83 $this->assertEquals( $vsize, $status[
'vsize'],
'vsize', $vsize * 0.1 );
131 if ( $expect instanceof Exception ) {
132 $this->setExpectedException( Scribunto_LuaError::class, $expect->getMessage() );
136 $ret = $interpreter->callFunction(
137 $interpreter->loadString(
"return { $lua }",
'test' )
139 if ( $expect instanceof Exception ) {
140 $this->fail(
'Expected exception not thrown' );
142 ksort( $ret[0], SORT_STRING );
143 $this->assertSame( $expect, $ret[0] );
191 $ret = $interpreter->callFunction(
192 $interpreter->loadString(
'return function() return "testFreeFunction #1" end',
'test' )
195 $interpreter->cleanupLuaChunks();
197 [
'testFreeFunction #1' ], $interpreter->callFunction( $ret[0] ),
198 'Test that function #1 was not freed while a reference exists'
201 $interpreter->cleanupLuaChunks();
204 $interpreter->callFunction( $testfunc );
205 $this->fail(
"Expected exception because function #1 should have been freed" );
208 "function id $id does not exist", $e->messageArgs[1],
209 'Testing for expected error when calling a freed function #1'
214 $ret = $interpreter->callFunction(
215 $interpreter->loadString(
'return function() return "testFreeFunction #2" end',
'test' )
220 $interpreter->cleanupLuaChunks();
222 [
'testFreeFunction #2' ], $interpreter->callFunction( $func ),
223 'Test that function #2 was not freed while a reference exists'
226 $interpreter->cleanupLuaChunks();
229 $interpreter->callFunction( $testfunc );
230 $this->fail(
"Expected exception because function #2 should have been freed" );
233 "function id $id does not exist", $e->messageArgs[1],
234 'Testing for expected error when calling a freed function #2'
239 $ret = $interpreter->callFunction(
240 $interpreter->loadString(
'return function() return "testFreeFunction #3" end',
'test' )
243 $func = clone $ret[0];
245 $interpreter->cleanupLuaChunks();
247 [
'testFreeFunction #3' ], $interpreter->callFunction( $func ),
248 'Test that function #3 was not freed while a reference exists'
251 $interpreter->cleanupLuaChunks();
254 $interpreter->callFunction( $testfunc );
255 $this->fail(
"Expected exception because function #3 should have been freed" );
258 "function id $id does not exist", $e->messageArgs[1],
259 'Testing for expected error when calling a freed function #3'