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:
Ian Farmer
2007-12-06 19:16:56 +00:00
parent 644896c467
commit a6f46413c0
3 changed files with 26 additions and 0 deletions

View File

@@ -74,6 +74,10 @@ public class LuaJTest extends TestCase {
runTest( "errors" );
}
public void testLoops() throws IOException, InterruptedException {
runTest( "loops" );
}
public void testMathLib() throws IOException, InterruptedException {
runTest( "mathlib" );
}

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

Binary file not shown.