mirror of
https://github.com/kikito/middleclass.git
synced 2024-11-08 09:34:22 +00:00
37 lines
967 B
Lua
37 lines
967 B
Lua
|
require 'middleclass'
|
||
|
|
||
|
context('class()', function()
|
||
|
|
||
|
context('when given no params', function()
|
||
|
test('it throws an error', function()
|
||
|
assert_error(class)
|
||
|
end)
|
||
|
end)
|
||
|
|
||
|
context('when given a name', function()
|
||
|
local TheClass = class('TheClass')
|
||
|
|
||
|
test('the resulting class has the correct name', function()
|
||
|
assert_equal(TheClass.name, 'TheClass')
|
||
|
end)
|
||
|
|
||
|
test('the resulting class has Object as its superclass', function()
|
||
|
assert_equal(TheClass.superclass, Object)
|
||
|
end)
|
||
|
end)
|
||
|
|
||
|
context('when given a name and a superclass', function()
|
||
|
local TheSuperClass = class('TheSuperClass')
|
||
|
local TheSubClass = class('TheSubClass', TheSuperClass)
|
||
|
|
||
|
test('the resulting class has the correct name', function()
|
||
|
assert_equal(TheSubClass.name, 'TheSubClass')
|
||
|
end)
|
||
|
|
||
|
test('the resulting class has the correct superclass', function()
|
||
|
assert_equal(TheSubClass.superclass, TheSuperClass)
|
||
|
end)
|
||
|
end)
|
||
|
|
||
|
end)
|