diff --git a/spec/metamethods_spec.lua b/spec/metamethods_spec.lua index 53fc645..234e618 100644 --- a/spec/metamethods_spec.lua +++ b/spec/metamethods_spec.lua @@ -40,6 +40,7 @@ describe('Metamethods', function() if type(b)=="number" then return a.class:new(a.x*b, a.y*b, a.z*b) end if type(a)=="number" then return b.class:new(a*b.x, a*b.y, a*b.z) end end + Vector.__metatable = "metatable of a vector" a = Vector:new(1,2,3) b = Vector:new(2,4,6) @@ -89,6 +90,10 @@ describe('Metamethods', function() assert.equal(4*a, Vector(4,8,12)) end) + it('implements __metatable', function() + assert.equal("metatable of a vector", getmetatable(a)) + end) + --[[ it('implements __index', function() assert.equal(b[1], 3) @@ -149,6 +154,10 @@ describe('Metamethods', function() assert.equal(4*c, Vector2(4,8,12)) end) + it('implements __metatable', function() + assert.equal("metatable of a vector", getmetatable(c)) + end) + describe('Updates', function() it('overrides __add', function() Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end