middleclass/spec/class_spec.lua

30 lines
884 B
Lua
Raw Normal View History

2013-09-15 21:14:00 +00:00
local class = require 'middleclass'
2013-09-15 21:18:08 +00:00
local Object = class.Object
2013-09-17 18:55:50 +00:00
describe('class()', function()
2013-09-17 18:55:50 +00:00
describe('when given no params', function()
it('it throws an error', function()
assert.error(class)
end)
end)
2013-09-17 18:55:50 +00:00
describe('when given a name', function()
it('the resulting class has the correct name and Object as its superclass', function()
2013-09-15 21:14:00 +00:00
local TheClass = class('TheClass')
2013-09-17 18:55:50 +00:00
assert.equal(TheClass.name, 'TheClass')
assert.equal(TheClass.super, Object)
end)
end)
2013-09-17 18:55:50 +00:00
describe('when given a name and a superclass', function()
it('the resulting class has the correct name and superclass', function()
2013-09-15 21:14:00 +00:00
local TheSuperClass = class('TheSuperClass')
local TheSubClass = class('TheSubClass', TheSuperClass)
2013-09-17 18:55:50 +00:00
assert.equal(TheSubClass.name, 'TheSubClass')
assert.equal(TheSubClass.super, TheSuperClass)
end)
end)
end)