diff --git a/middleclass.lua b/middleclass.lua index 8bef0fb..dae6496 100644 --- a/middleclass.lua +++ b/middleclass.lua @@ -66,16 +66,6 @@ end -- creates a subclass function Object.subclass(klass, name) - assert(_classes[klass], "Use Class:subclass instead of Class.subclass") - assert( type(name)=="string", "You must provide a name(string) for your class") - - local thesubclass = { name = name, super = klass, __classDict = {}, __mixins={} } - - local dict = thesubclass.__classDict -- classDict contains all the [meta]methods of the class - dict.__index = dict -- It "points to itself" so instances can use it as a metatable. - local superDict = klass.__classDict -- The super' classDict - - setmetatable(dict, superDict) -- when a method isn't found on classDict, 'escalate upwards'. setmetatable(thesubclass, { __index = dict, -- look for stuff on the dict diff --git a/spec/Object_spec.lua b/spec/Object_spec.lua index 83ce552..2bc660b 100644 --- a/spec/Object_spec.lua +++ b/spec/Object_spec.lua @@ -13,14 +13,13 @@ context('Object', function() assert_equal(tostring(Object), 'class Object') end) end) - - context('Object()', function() + + context('()', function() test('returns an object, like Object:new()', function() local obj = Object() - assert_true(instanceOf(Object)) + assert_true(instanceOf(Object, obj)) end) end) - context('instance creation', function() diff --git a/spec/classes_spec.lua b/spec/classes_spec.lua index 813d487..4562e53 100644 --- a/spec/classes_spec.lua +++ b/spec/classes_spec.lua @@ -16,6 +16,14 @@ context('Class', function() end) end) + context('()', function() + test('returns an object, like Class:new()', function() + local TheClass = class('TheClass') + local obj = TheClass() + assert_true(instanceOf(TheClass, obj)) + end) + end) + context('attributes', function() local A, B