Add simple test for correct upvalue handling.
This commit is contained in:
@@ -43,6 +43,10 @@ public class LuaJTest extends TestCase {
|
|||||||
runTest( "test7" );
|
runTest( "test7" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testUpvalues() throws IOException, InterruptedException {
|
||||||
|
runTest( "upvalues" );
|
||||||
|
}
|
||||||
|
|
||||||
private void runTest( String testName ) throws IOException, InterruptedException {
|
private void runTest( String testName ) throws IOException, InterruptedException {
|
||||||
// add LuaJava bindings
|
// add LuaJava bindings
|
||||||
LuaJava.install();
|
LuaJava.install();
|
||||||
|
|||||||
25
src/test/res/upvalues.lua
Normal file
25
src/test/res/upvalues.lua
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
function test()
|
||||||
|
local x = 5
|
||||||
|
function f()
|
||||||
|
x = x + 1
|
||||||
|
return x
|
||||||
|
end
|
||||||
|
function g()
|
||||||
|
x = x - 1
|
||||||
|
return x
|
||||||
|
end
|
||||||
|
print(f())
|
||||||
|
print(g())
|
||||||
|
return f, g
|
||||||
|
end
|
||||||
|
|
||||||
|
f1, g1 = test()
|
||||||
|
print("f1()=", f1())
|
||||||
|
print("g1()=", g1())
|
||||||
|
|
||||||
|
f2, g2 = test()
|
||||||
|
print("f2()=", f2())
|
||||||
|
print("g2()=", g2())
|
||||||
|
|
||||||
|
print("g1()=", g1())
|
||||||
|
print("f1()=", f1())
|
||||||
BIN
src/test/res/upvalues.luac
Normal file
BIN
src/test/res/upvalues.luac
Normal file
Binary file not shown.
Reference in New Issue
Block a user