mirror of
https://github.com/kikito/middleclass.git
synced 2024-11-25 02:44:20 +00:00
Fix not inheriting metamethods from grandparent class
This commit is contained in:
parent
b66ba54ccb
commit
524d0ddc8c
@ -97,7 +97,7 @@ local function _createClass(name, super)
|
||||
end
|
||||
|
||||
local function _setSubclassMetamethods(aClass, subclass)
|
||||
for m in pairs(aClass.__metamethods) do
|
||||
for m in pairs(all_metamethods) do
|
||||
subclass.__instanceDict[m] = aClass.__instanceDict[m]
|
||||
end
|
||||
end
|
||||
|
@ -171,6 +171,13 @@ describe('Metamethods', function()
|
||||
for k in pairs(c) do assert.not_table(k) end
|
||||
end)
|
||||
|
||||
it('allows inheriting further', function()
|
||||
local Vector3 = class('Vector3', Vector2)
|
||||
local e = Vector3(1,2,3)
|
||||
local f = Vector3(3,4,5)
|
||||
assert.equal(e+f, Vector3(4,6,8))
|
||||
end)
|
||||
|
||||
describe('Updates', function()
|
||||
it('overrides __add', function()
|
||||
Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end
|
||||
|
Loading…
Reference in New Issue
Block a user