Permalink
Browse files

lua 5.2 compatibility: replace foreachi with ipairs

  • Loading branch information...
1 parent 5c6962c commit 66c39731113c8f6d005a9b85739202e4afce3dd2 @justincormack justincormack committed Jun 6, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 luaunit.lua
View
@@ -305,7 +305,7 @@ local UnitResult = { -- class
if #self.errorList == 0 then return end
print("Failed tests:")
print("-------------")
- table.foreachi(self.errorList, self.displayOneFailedTest)
+ for i,v in ipairs(self.errorList) do self.displayOneFailedTest(i, v) end
end
function UnitResult:displayFinalResult()
@@ -411,7 +411,7 @@ local LuaUnit = {
testFunction = _G[testName]
testClass[testName] = testFunction
end
- table.foreachi( {...}, storeAsMethod )
+ for i, v in ipairs {...} do storeAsMethod(i, v) end
return testClass
end
@@ -521,11 +521,11 @@ local LuaUnit = {
-- that you want to run
args = {...}
if #args > 0 then
- table.foreachi( args, LuaUnit.runTestClassByName )
+ for i, v in ipairs(args) do LuaUnit.runTestClassByName(i, v) end
else
if argv and #argv > 1 then
-- Run files passed on the command line
- table.foreachi(argv, LuaUnit.runTestClassByName )
+ for i, v in ipairs(argv) do LuaUnit.runTestClassByName(i, v) end
else
-- create the list before. If you do not do it now, you
-- get undefined result because you modify _G while iterating

0 comments on commit 66c3973

Please sign in to comment.