middleclass/spec/class_spec.lua

38 lines
918 B
Lua
Raw Normal View History

require('MiddleClass')
context( 'class', function()
context( 'When creating a class', function()
context( 'using class("name")', function()
local TheClass = class('TheClass')
2010-07-28 23:18:11 +00:00
test( 'should have the correct name', function()
assert_equal(TheClass.name, 'TheClass')
end)
2010-07-28 23:18:11 +00:00
test( 'should have Object as their superclass', function()
assert_equal(TheClass.superclass, Object)
end)
end)
context( 'using class("name", AClass)', function()
local TheSuperClass = class('TheSuperClass')
local TheSubClass = class('TheSubClass', TheSuperClass)
2010-07-28 23:18:11 +00:00
test( 'should have the correct superclass', function()
assert_equal(TheSubClass.superclass, TheSuperClass)
end)
end)
context( 'using no name', function()
test( 'class() should throw an error', function()
assert_error(class)
end)
end)
end)
end)