2010-07-27 23:32:10 +00:00
|
|
|
require('MiddleClass')
|
|
|
|
|
2010-07-22 22:56:40 +00:00
|
|
|
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()
|
2010-07-22 22:56:40 +00:00
|
|
|
assert_equal(TheClass.name, 'TheClass')
|
|
|
|
end)
|
|
|
|
|
2010-07-28 23:18:11 +00:00
|
|
|
test( 'should have Object as their superclass', function()
|
2010-07-22 22:56:40 +00:00
|
|
|
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()
|
2010-07-22 22:56:40 +00:00
|
|
|
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)
|