lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 21.09.2012 04:09, mitch abaza wrote:
> I come from a heavy TDD/OOP background and I'm finding it challenging to
> apply the same testing discipline to Lua. 

Have you read any of those? http://lua-users.org/wiki/UnitTesting

> I'm told you can't do reference equality on functions.  If true, how
> would I test that the returned table contains a "reference" to the
> filterRuleProvider.filterEmptyMessages function?  

Not sure if I understand you correctly, but of course you can check if
two variables reference the same function, so that should work also in
your case:

a=function()
  print('Hello world!')
end
b=a

c=function()
  print('Hello world!')
end
print(a, b, c)
print(a==b, a==c)
T={a, b, c}
for k,v in ipairs(T) do
  print('Equals? ', a==v)
end


Tested on Lua 5.1, but it should work for Lua 5.2..
Regards,
miko