mirror of
https://github.com/php-win-ext/php-lua.git
synced 2026-03-24 00:52:12 +01:00
added test for "php closures from lua" functionality
This commit is contained in:
30
tests/013.phpt
Normal file
30
tests/013.phpt
Normal file
@@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
PHP Closures from Lua
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("lua")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$l = new lua();
|
||||
$l->eval(<<<CODE
|
||||
function test(cb1)
|
||||
local cb2 = cb1("called from lua")
|
||||
cb2("returned from php")
|
||||
end
|
||||
CODE
|
||||
);
|
||||
|
||||
try {
|
||||
$l->test(function($msg) {
|
||||
print "$msg";
|
||||
|
||||
return function($msg) {
|
||||
print "$msg";
|
||||
};
|
||||
});
|
||||
} catch(LuaException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
called from luareturned from php
|
||||
Reference in New Issue
Block a user