diff --git a/src/test/java/lua/LuaJTest.java b/src/test/java/lua/LuaJTest.java index 3d22b0b0..2147ae5b 100644 --- a/src/test/java/lua/LuaJTest.java +++ b/src/test/java/lua/LuaJTest.java @@ -43,6 +43,10 @@ public class LuaJTest extends TestCase { runTest( "test7" ); } + public void testUpvalues() throws IOException, InterruptedException { + runTest( "upvalues" ); + } + private void runTest( String testName ) throws IOException, InterruptedException { // add LuaJava bindings LuaJava.install(); diff --git a/src/test/res/upvalues.lua b/src/test/res/upvalues.lua new file mode 100644 index 00000000..ea760070 --- /dev/null +++ b/src/test/res/upvalues.lua @@ -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()) diff --git a/src/test/res/upvalues.luac b/src/test/res/upvalues.luac new file mode 100644 index 00000000..4ad04e3d Binary files /dev/null and b/src/test/res/upvalues.luac differ