Lua has a number of default metamethods (Lua 5.3 Manual -> 2.4 – Metatables and Metamethods) that defines an object behaviour for example for default Lua operators. Most of these metamethods can be covered by general properties. For example if a and b have metamethod __eq then (a == b) == (b == a) and (a == b) ~= (a ~= b), for metamethod __lt - (a > b) == (b < a) and so on. I believe it would simplify testing a bit if lua-quickcheck will discover available metamethods and them with such properties.
What do you think, @luc-tielen? I'm ready to spend some time implementing this.
General methods
__index - none?
__newindex - none?
__mode - none?
__call - none?
__metatable - none?
__tostring
type(tostring(a)) == 'string'
__pairs - none?
__ipairs - none?
__gc - none?
__name
type(a.__name() == 'string'
Mathematic Operators
a + b == b + a
a + 0 == a
a * 2 == a + a
a * 1 == a * 1 * 1
__div - none?
__idiv - none?
__mod
a % b == a - math.floor(a / b) * b
Bitwise Operators
(a & (a - 1)) == 0, if a is x^2
Equivalence Comparison Operators
(a == b) == (b == a)
(a == b) ~= (a ~= b)
Lua has a number of default metamethods (Lua 5.3 Manual -> 2.4 – Metatables and Metamethods) that defines an object behaviour for example for default Lua operators. Most of these metamethods can be covered by general properties. For example if
aandbhave metamethod__eqthen(a == b) == (b == a)and(a == b) ~= (a ~= b), for metamethod__lt-(a > b) == (b < a)and so on. I believe it would simplify testing a bit if lua-quickcheck will discover available metamethods and them with such properties.What do you think, @luc-tielen? I'm ready to spend some time implementing this.
General methods
__index- none?__newindex- none?__mode- none?__call- none?__metatable- none?__tostring__len__pairs- none?__ipairs- none?__gc- none?__name__closeMathematic Operators
__unm__add__sub- none?__mul__div- none?__idiv- none?__mod__pow__concat- none?Bitwise Operators
__band__bor__bxor__bnot__shl__shrEquivalence Comparison Operators
__eq__lt__le