X7ROOT File Manager
Current Path:
/opt/alt/tests/alt-php80-pecl-luasandbox_4.1.2-2.el8/tests
opt
/
alt
/
tests
/
alt-php80-pecl-luasandbox_4.1.2-2.el8
/
tests
/
ðŸ“
..
📄
LuaSandboxFunction_construct.phpt
(253 B)
📄
array-key-conversion.phpt
(3.11 KB)
📄
call.phpt
(5.1 KB)
📄
callback_exception.phpt
(392 B)
📄
datatypes-unsupported.phpt
(2.78 KB)
📄
datatypes.phpt
(2.43 KB)
📄
dump_loadBinary_call.phpt
(393 B)
📄
errors-at-call-boundaries.phpt
(1.98 KB)
📄
extending-LuaSandbox.phpt
(845 B)
📄
ipairs.phpt
(1.53 KB)
📄
loadString.phpt
(334 B)
📄
lua_catches_php_exception.phpt
(1.34 KB)
📄
pairs.phpt
(3.31 KB)
📄
pcall.phpt
(1.27 KB)
📄
profiler-sorting.phpt
(1.18 KB)
📄
profiler.phpt
(1.54 KB)
📄
reentrant.phpt
(1.1 KB)
📄
xpcall.phpt
(2.6 KB)
Editing: array-key-conversion.phpt
--TEST-- Array key conversion --FILE-- <?php function testPhpToLua( $test, $array ) { printf( "PHP→Lua %-30s ", "$test:" ); $sandbox = new LuaSandbox; $sandbox->setMemoryLimit( 100000 ); $sandbox->setCPULimit( 0.1 ); try { $ret = $sandbox ->loadString( 'local t, r = ..., {}; for k, v in pairs( t ) do r[v] = type(k) end return r' ) ->call( $array ); if ( is_array( $ret[0] ) ) { ksort( $ret[0], SORT_STRING ); } printf( "%s\n", preg_replace( '/\s+/', ' ', var_export( $ret[0], 1 ) ) ); } catch ( LuaSandboxError $e ) { printf( "EXCEPTION: %s\n", $e->getMessage() ); } } function testLuaToPhp( $test, $lua ) { printf( "Lua→PHP %-30s ", "$test:" ); $sandbox = new LuaSandbox; $sandbox->setMemoryLimit( 100000 ); $sandbox->setCPULimit( 0.1 ); try { $ret = $sandbox->loadString( "return { $lua }" )->call(); if ( is_array( $ret[0] ) ) { ksort( $ret[0], SORT_STRING ); } printf( "%s\n", preg_replace( '/\s+/', ' ', var_export( $ret[0], 1 ) ) ); } catch ( LuaSandboxError $e ) { printf( "EXCEPTION: %s\n", $e->getMessage() ); } } if ( PHP_INT_MAX > 9007199254740992 ) { $a = [ '9007199254740992' => 'max', '9007199254740993' => 'max+1', '-9007199254740992' => 'min', '-9007199254740993' => 'min-1', ]; $max = '9223372036854775807'; $max2 = '9223372036854775808'; $min = '-9223372036854775808'; $min2 = '-9223372036854775809'; } else { $a = [ '2147483647' => 'max', '2147483648' => 'max+1', '-2147483648' => 'min', '-2147483649' => 'min-1', ]; $max = '2147483647'; $max2 = '2147483648'; $min = '-2147483648'; $min2 = '-2147483649'; } testPhpToLua( 'simple integers', [ -10 => 'minus ten', 0 => 'zero', 10 => 'ten' ] ); testPhpToLua( 'maximal values', $a ); testLuaToPhp( 'simple integers', '[-10] = "minus ten", [0] = "zero", [10] = "ten"' ); testLuaToPhp( 'stringified integers', '["-10"] = "minus ten", ["0"] = "zero", ["10"] = "ten"' ); testLuaToPhp( 'maximal integers', "['$max'] = 'max', ['$max2'] = 'max+1', ['$min'] = 'min', ['$min2'] = 'min-1'" ); testLuaToPhp( 'collision (0)', '[0] = "number zero", ["0"] = "string zero"' ); testLuaToPhp( 'collision (float)', '[1.5] = "number 1.5", ["1.5"] = "string 1.5"' ); testLuaToPhp( 'collision (inf)', '[1/0] = "number inf", ["inf"] = "string inf"' ); --EXPECTF-- PHP→Lua simple integers: array ( 'minus ten' => 'number', 'ten' => 'number', 'zero' => 'number', ) PHP→Lua maximal values: array ( 'max' => 'number', 'max+1' => 'string', 'min' => 'number', 'min-1' => 'string', ) Lua→PHP simple integers: array ( -10 => 'minus ten', 0 => 'zero', 10 => 'ten', ) Lua→PHP stringified integers: array ( -10 => 'minus ten', 0 => 'zero', 10 => 'ten', ) Lua→PHP maximal integers: array ( -%d => 'min', '-%d' => 'min-1', %d => 'max', '%d' => 'max+1', ) Lua→PHP collision (0): EXCEPTION: Collision for array key 0 when passing data from Lua to PHP Lua→PHP collision (float): EXCEPTION: Collision for array key 1.5 when passing data from Lua to PHP Lua→PHP collision (inf): EXCEPTION: Collision for array key inf when passing data from Lua to PHP
Upload File
Create Folder