@@ -2,46 +2,46 @@ describe("Common", function()
22 describe (" Class creation and use" , function ()
33 it (" produces error when parent constructors are not called" , function ()
44 local ParentClass = newClass (" ConstructorTestParentClass" )
5- function ParentClass :ConstructorTestParentClass ()
5+ function ParentClass :init ()
66 return self
77 end
88 local ChildClass = newClass (" ConstructorTestProblemChildClass" , " ConstructorTestParentClass" )
9- function ChildClass :ConstructorTestProblemChild ()
9+ function ChildClass :init ()
1010 -- Intentionally does not call self:ConstructorTestParentClass()
1111 return self
1212 end
1313 common .classes .ConstructorTestParent = ParentClass
1414 common .classes .ConstructorTestProblemChild = ChildClass
1515
1616 assert .has_error (function ()
17- new (" ConstructorTestProblemChild" ):ConstructorTestProblemChild ()
17+ new (" ConstructorTestProblemChild" ):init ()
1818 end , " Parent class 'ConstructorTestParentClass' of class 'ConstructorTestProblemChild' must be initialised" )
1919 common .classes .ConstructorTestParent = nil
2020 common .classes .ConstructorTestProblemChild = nil
2121 end )
2222 it (" produces an error if additional arguments are passed" , function ()
2323 local StupidClass = newClass (" NewAbuse" )
24- function StupidClass :NewAbuse (someParam )
24+ function StupidClass :init (someParam )
2525 return self
2626 end
2727
2828 common .classes .NewAbuse = StupidClass
2929
3030 assert .has_no .errors (function ()
31- local newObj = new (" NewAbuse" ):NewAbuse (" fish" )
31+ local newObj = new (" NewAbuse" ):init (" fish" )
3232 end )
3333 assert .has_error (function ()
3434 local newObj = new (" NewAbuse" , " look I'm using the old syntax" )
3535 end )
3636 end )
3737 it (" produces an error if it calls a parent class without giving it self" , function ()
3838 local ParentClass = newClass (" ConstructorTestParentClass" )
39- function ParentClass :ConstructorTestParentClass ()
39+ function ParentClass :init ()
4040 return self
4141 end
4242
4343 local ChildClass = newClass (" ConstructorTestProblemChildClass" , " ConstructorTestParentClass" )
44- function ChildClass :ConstructorTestProblemChild ()
44+ function ChildClass :init ()
4545 self .ConstructorTestParentClass ()
4646 return self
4747 end
@@ -50,20 +50,20 @@ describe("Common", function()
5050 common .classes .ConstructorTestProblemChild = ChildClass
5151
5252 assert .has_error (function ()
53- new (" ConstructorTestProblemChild" ):ConstructorTestProblemChild ()
53+ new (" ConstructorTestProblemChild" ):init ()
5454 end )
5555 common .classes .ConstructorTestParent = nil
5656 common .classes .ConstructorTestProblemChild = nil
5757 end )
5858 it (" produces an error if its constructor doesn't return the object" , function ()
5959 local StupidClass = newClass (" StupidClass" )
60- function StupidClass :StupidClass ()
60+ function StupidClass :init ()
6161 end
6262
6363 common .classes .StupidClass = StupidClass
6464
6565 assert .has_error (function ()
66- new (" StupidClass" ):StupidClass ()
66+ new (" StupidClass" ):init ()
6767 end , " Class StupidClass constructor did not return a value" )
6868 end )
6969 end )
0 commit comments