Skip to content

Commit 922f693

Browse files
committed
rename constructors to init instead of the class name
1 parent 1c4c3cd commit 922f693

97 files changed

Lines changed: 1371 additions & 1371 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

spec/System/TestCommon_spec.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

spec/System/TestCompareBuySimilar_spec.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe("Buy similar mod stat matching", function()
44

55
describe("addModEntries mod matching", function()
66
it("matches impossible escape mods as options", function()
7-
local fromNothing = new("Item"):Item([[
7+
local fromNothing = new("Item"):init([[
88
Impossible Escape
99
Viridian Jewel
1010
LevelReq: 0
@@ -32,7 +32,7 @@ Corrupted]])
3232
end)
3333

3434
it("matches thread of hope radius as an option", function()
35-
local thread = new("Item"):Item([[
35+
local thread = new("Item"):init([[
3636
Rarity: UNIQUE
3737
Thread of Hope
3838
Crimson Jewel
@@ -52,7 +52,7 @@ Passage]])
5252
end)
5353

5454
it("combines mods that are the same stat", function()
55-
local lifeDiamond = new("Item"):Item([[
55+
local lifeDiamond = new("Item"):init([[
5656
Test Subject
5757
Diamond
5858
Implicits: 0
@@ -67,7 +67,7 @@ Implicits: 0
6767
assert.equal("+50 to Maximum Life", StripEscapes(entries[1].formattedLines[2]))
6868
assert.equal(150, entries[1].value)
6969

70-
local lifelessDiamond = new("Item"):Item([[
70+
local lifelessDiamond = new("Item"):init([[
7171
Test Subject
7272
Diamond
7373
Implicits: 0
@@ -82,7 +82,7 @@ Implicits: 0
8282
end)
8383

8484
it("is not case-sensitive", function ()
85-
local funnyItem = new("Item"):Item([[
85+
local funnyItem = new("Item"):init([[
8686
Test Subject
8787
Diamond
8888
Implicits: 1
@@ -93,7 +93,7 @@ Implicits: 1
9393
end)
9494

9595
it("does not combine implicit and explicit mods", function()
96-
local lifelessDiamond = new("Item"):Item([[
96+
local lifelessDiamond = new("Item"):init([[
9797
Test Subject
9898
Diamond
9999
Implicits: 1
@@ -140,7 +140,7 @@ Implicits: 1
140140
end)
141141

142142
local function openPopup(item, slotName)
143-
item = item or new("Item"):Item("Rarity: Rare\nTest Ring\nRuby Ring\nImplicits: 0\n+50 to maximum Life")
143+
item = item or new("Item"):init("Rarity: Rare\nTest Ring\nRuby Ring\nImplicits: 0\n+50 to maximum Life")
144144
bs.openPopup(item, slotName or "Ring", build)
145145
local controls = main.popups[1].controls
146146
_G.Copy = function(url) copiedUrl = url end
@@ -194,7 +194,7 @@ Implicits: 1
194194
end)
195195

196196
it("encodes option values in the generated query", function()
197-
local item = new("Item"):Item([[
197+
local item = new("Item"):init([[
198198
Rarity: UNIQUE
199199
Impossible Escape
200200
Viridian Jewel
@@ -214,7 +214,7 @@ Corrupted]])
214214
end)
215215

216216
it("inverts reduced stat bounds in the generated query", function()
217-
local item = new("Item"):Item([[
217+
local item = new("Item"):init([[
218218
Rarity: Rare
219219
Test Ring
220220
Ruby Ring
@@ -230,7 +230,7 @@ Implicits: 0
230230
end)
231231

232232
it("uses a count group for ambiguous trade stats", function()
233-
local item = new("Item"):Item([[
233+
local item = new("Item"):init([[
234234
Rarity: Rare
235235
Test Ring
236236
Ruby Ring

spec/System/TestImport_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe("TestImport", function()
7171
end)
7272

7373
function importAndReimportWithOldJewel(shouldDelete)
74-
local oldJewel = new("Item"):Item([[Rarity: RARE
74+
local oldJewel = new("Item"):init([[Rarity: RARE
7575
TEST JEWEL
7676
Crimson Jewel
7777
Crafted: true

spec/System/TestItemDBControl_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe("ItemDBControl", function()
3333
return item ~= invalidItem
3434
end,
3535
}
36-
local control = new("ItemDBControl"):ItemDBControl(nil, { 0, 0, 100, 100 }, itemsTab, {
36+
local control = new("ItemDBControl"):init(nil, { 0, 0, 100, 100 }, itemsTab, {
3737
list = { invalidItem, betterItem, worseItem },
3838
}, "RARE")
3939
control.sortDetail = {

spec/System/TestItemMods_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,12 +614,12 @@ describe("TetsItemMods", function()
614614
end)
615615

616616
it("shows a fallback tooltip when an item's base is no longer supported", function()
617-
local item = new("Item"):Item([[
617+
local item = new("Item"):init([[
618618
Rarity: Unique
619619
Legacy Item
620620
Removed Base
621621
]])
622-
local tooltip = new("Tooltip"):Tooltip()
622+
local tooltip = new("Tooltip"):init()
623623

624624
assert.has_no.errors(function()
625625
build.itemsTab:AddItemTooltip(tooltip, item)

0 commit comments

Comments
 (0)