求一个lua的 测试用例

function Class(base , ctor)
local c = {}
if not _ctor and type(base) == 'function' then
_ctor = base
base = nil
elseif type(base) =='table' then
for i,v in pairs(base) do
c[i] = v
end
c._base = base
end
c.
_index =c
mt ={}
mt.__call = function(class_tb1,...)
local obj = {}
setmetatable(obj,c)
if _ctor then
_ctor(obj,...)
end
return obj
end
c._ctor = _ctor
c.is_a = function(self , klass)
local m = getmetatable(self)
local index = 0
while m do

        if m == klass then return true end
        m = m._base;
        index = index + 1
    end
    return false
end
setmetatable(c,mt)
return c

end
用这个写个用例 求教

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!