Added 'loops' test case.
This script tests the generic for loop using a Lua closure as the iterator function, which is currently broken.
This commit is contained in:
@@ -74,6 +74,10 @@ public class LuaJTest extends TestCase {
|
|||||||
runTest( "errors" );
|
runTest( "errors" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testLoops() throws IOException, InterruptedException {
|
||||||
|
runTest( "loops" );
|
||||||
|
}
|
||||||
|
|
||||||
public void testMathLib() throws IOException, InterruptedException {
|
public void testMathLib() throws IOException, InterruptedException {
|
||||||
runTest( "mathlib" );
|
runTest( "mathlib" );
|
||||||
}
|
}
|
||||||
|
|||||||
22
src/test/res/loops.lua
Normal file
22
src/test/res/loops.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
-- This script tests the "generic" for loop with a script iterator.
|
||||||
|
|
||||||
|
local function stuff()
|
||||||
|
local function i(o)
|
||||||
|
if o.counter > 3 then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
local v = o.counter
|
||||||
|
o.counter = v + 1
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return i, { counter=1 }
|
||||||
|
end
|
||||||
|
|
||||||
|
local function testfor()
|
||||||
|
for x in stuff() do
|
||||||
|
print(x)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
testfor()
|
||||||
BIN
src/test/res/loops.luac
Normal file
BIN
src/test/res/loops.luac
Normal file
Binary file not shown.
Reference in New Issue
Block a user