Add simple test for correct upvalue handling.

This commit is contained in:
Ian Farmer
2007-07-09 01:43:34 +00:00
parent 62022d5881
commit 45964d7e22
3 changed files with 29 additions and 0 deletions

View File

@@ -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();

25
src/test/res/upvalues.lua Normal file
View 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

Binary file not shown.