vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | ------------------------------------------------------ |
2 | -- HuntersHelper_Tests.lua |
||
3 | -- testing functions for verifying our tables |
||
4 | ------------------------------------------------------ |
||
5 | |||
6 | function FHH_RunAllTests() |
||
7 | local testNum = 1; |
||
8 | local errorCount = 0; |
||
9 | while (errorCount == 0 and getglobal("FHH_Test"..testNum) ~= nil) do |
||
10 | local testFunc = getglobal("FHH_Test"..testNum) |
||
11 | errorCount = testFunc(); |
||
12 | testNum = testNum + 1; |
||
13 | end |
||
14 | end |
||
15 | |||
16 | function FHH_Test1() |
||
17 | -- 1: make sure all spell-indexed tables have the same spells |
||
18 | local errorCount = 0; |
||
19 | for spellID in FHH_SpellInfo do |
||
20 | if (FHH_RequiredLevel[spellID] == nil) then |
||
21 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(spellID).." present in FHH_SpellInfo but not FHH_RequiredLevel."); |
||
22 | errorCount = errorCount + 1; |
||
23 | end |
||
24 | if (FHH_LearnableBy[spellID] == nil) then |
||
25 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(spellID).." present in FHH_SpellInfo but not FHH_LearnableBy."); |
||
26 | errorCount = errorCount + 1; |
||
27 | end |
||
28 | end |
||
29 | for spellID in FHH_RequiredLevel do |
||
30 | if (FHH_SpellInfo[spellID] == nil) then |
||
31 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(spellID).." present in FHH_RequiredLevel but not FHH_SpellInfo."); |
||
32 | errorCount = errorCount + 1; |
||
33 | end |
||
34 | if (FHH_LearnableBy[spellID] == nil) then |
||
35 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(spellID).." present in FHH_RequiredLevel but not FHH_LearnableBy."); |
||
36 | errorCount = errorCount + 1; |
||
37 | end |
||
38 | end |
||
39 | for spellID in FHH_LearnableBy do |
||
40 | if FHH_SpellInfo[spellID] == nil then |
||
41 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(spellID).." present in FHH_LearnableBy but not FHH_SpellInfo."); |
||
42 | errorCount = errorCount + 1; |
||
43 | end |
||
44 | if FHH_RequiredLevel[spellID] == nil then |
||
45 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(spellID).." present in FHH_LearnableBy but not FHH_RequiredLevel."); |
||
46 | errorCount = errorCount + 1; |
||
47 | end |
||
48 | end |
||
49 | if (errorCount == 0) then |
||
50 | GFWUtils.Print("Test 1 passed; all spell-indexed tables have the same set of indices."); |
||
51 | end |
||
52 | return errorCount; |
||
53 | end |
||
54 | |||
55 | function FHH_Test2() |
||
56 | -- 2: check spell ranks from FHH_SpellInfo against FHH_RequiredLevel |
||
57 | local errorCount = 0; |
||
58 | for spellID, ranksTable in FHH_SpellInfo do |
||
59 | if (type(ranksTable) == "table" and table.getn(ranksTable) ~= table.getn(FHH_RequiredLevel[spellID])) then |
||
60 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ").."FHH_SpellInfo and FHH_RequiredLevel do not cover the same set of ranks for "..GFWUtils.Hilite(spellID).."."); |
||
61 | errorCount = errorCount + 1; |
||
62 | end |
||
63 | end |
||
64 | if (errorCount == 0) then |
||
65 | GFWUtils.Print("Test 2 passed; all spell ranks match in FHH_SpellInfo and FHH_RequiredLevel."); |
||
66 | end |
||
67 | return errorCount; |
||
68 | end |
||
69 | |||
70 | function FHH_Test3() |
||
71 | -- 3: make sure every beast listed in FHH_SpellInfo has info in FHH_BeastLevels |
||
72 | local errorCount = 0; |
||
73 | for spellID, ranksTable in FHH_SpellInfo do |
||
74 | if (type(ranksTable) == "table") then |
||
75 | for rankNum, zonesTable in ranksTable do |
||
76 | for zoneName, beastsTable in zonesTable do |
||
77 | for _, beastName in beastsTable do |
||
78 | local beastLevelInfo = FHH_BeastLevels[beastName]; |
||
79 | if (beastLevelInfo == nil) then |
||
80 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." listed in FHH_SpellInfo but not FHH_BeastLevels."); |
||
81 | errorCount = errorCount + 1; |
||
82 | if (FHH_Config.tempBeastLevels == nil) then |
||
83 | FHH_Config.tempBeastLevels = {}; |
||
84 | end |
||
85 | FHH_Config.tempBeastLevels[beastName] = { min=1, max=1 }; -- use a saved var to build dummy table for easy editing |
||
86 | else |
||
87 | if (beastLevelInfo.min == nil or tonumber(beastLevelInfo.min) == nil or beastLevelInfo.min < 1 or beastLevelInfo.min > 60) then |
||
88 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." has illegal minimum level listed in FHH_BeastLevels."); |
||
89 | errorCount = errorCount + 1; |
||
90 | end |
||
91 | if (beastLevelInfo.max ~= nil and (tonumber(beastLevelInfo.max) == nil or beastLevelInfo.max < 1 or beastLevelInfo.max > 60)) then |
||
92 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." has illegal maximum level listed in FHH_BeastLevels."); |
||
93 | errorCount = errorCount + 1; |
||
94 | end |
||
95 | end |
||
96 | end |
||
97 | end |
||
98 | end |
||
99 | end |
||
100 | end |
||
101 | if (errorCount == 0) then |
||
102 | GFWUtils.Print("Test 3 passed; all beasts in FHH_SpellInfo have levels in FHH_BeastLevels."); |
||
103 | end |
||
104 | return errorCount; |
||
105 | end |
||
106 | |||
107 | function FHH_Test4() |
||
108 | -- 4: make sure all appropriate info in FHH_SpellInfo is mirrored in FHH_BeastInfo |
||
109 | local errorCount = 0; |
||
110 | for spellID, ranksTable in FHH_SpellInfo do |
||
111 | if (type(ranksTable) == "table") then |
||
112 | for rankNum, zonesTable in ranksTable do |
||
113 | local niceSpellName = FHH_SpellDescription(spellID, rankNum); |
||
114 | for zoneName, beastsTable in zonesTable do |
||
115 | for _, beastName in beastsTable do |
||
116 | if (FHH_BeastInfo[beastName] == nil) then |
||
117 | if (FHH_NewInfo == nil) then |
||
118 | FHH_NewInfo = {}; |
||
119 | end |
||
120 | if (FHH_NewInfo.BeastInfo == nil) then |
||
121 | FHH_NewInfo.BeastInfo = {}; |
||
122 | end |
||
123 | if (FHH_NewInfo.BeastInfo[beastName] == nil) then |
||
124 | FHH_NewInfo.BeastInfo[beastName] = {}; |
||
125 | end |
||
126 | FHH_NewInfo.BeastInfo[beastName][spellID] = rankNum; |
||
127 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." not present in FHH_BeastInfo; added to FHH_NewInfo.BeastInfo with "..GFWUtils.Hilite(niceSpellName).."."); |
||
128 | errorCount = errorCount + 1; |
||
129 | elseif (FHH_BeastInfo[beastName][spellID] == nil or FHH_BeastInfo[beastName][spellID] ~= rankNum) then |
||
130 | if (FHH_NewInfo == nil) then |
||
131 | FHH_NewInfo = {}; |
||
132 | end |
||
133 | if (FHH_NewInfo.BeastInfo == nil) then |
||
134 | FHH_NewInfo.BeastInfo = {}; |
||
135 | end |
||
136 | if (FHH_NewInfo.BeastInfo[beastName] == nil) then |
||
137 | FHH_NewInfo.BeastInfo[beastName] = {}; |
||
138 | end |
||
139 | FHH_NewInfo.BeastInfo[beastName][spellID] = rankNum; |
||
140 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(niceSpellName).." not present in FHH_BeastInfo for "..GFWUtils.Hilite(beastName).."; added to FHH_NewInfo.BeastInfo."); |
||
141 | errorCount = errorCount + 1; |
||
142 | end |
||
143 | end |
||
144 | end |
||
145 | end |
||
146 | end |
||
147 | end |
||
148 | if (errorCount == 0) then |
||
149 | GFWUtils.Print("Test 4 passed; all appropriate info from FHH_SpellInfo is mirrored in FHH_BeastInfo."); |
||
150 | end |
||
151 | return errorCount; |
||
152 | end |
||
153 | |||
154 | function FHH_Test5() |
||
155 | -- 5: vice versa; make sure everything from FHH_BeastInfo is mirrored in FHH_SpellInfo |
||
156 | local errorCount = 0; |
||
157 | for beastName, spellsTable in FHH_BeastInfo do |
||
158 | for spellID, rankNum in spellsTable do |
||
159 | local niceSpellName = FHH_SpellDescription(spellID, rankNum); |
||
160 | local spellTable = FHH_SpellInfo[spellID]; |
||
161 | if (spellTable == nil) then |
||
162 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." has spell "..GFWUtils.Hilite(spellID).." which is unknown in FHH_SpellInfo."); |
||
163 | errorCount = errorCount + 1; |
||
164 | else |
||
165 | local zonesTable = spellTable[rankNum]; |
||
166 | if (zonesTable == nil) then |
||
167 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." has spell rank "..GFWUtils.Hilite(niceSpellName).." which is unknown in FHH_SpellInfo."); |
||
168 | errorCount = errorCount + 1; |
||
169 | else |
||
170 | local foundBeast = false; |
||
171 | for zoneName, beastsTable in zonesTable do |
||
172 | for _, aBeast in beastsTable do |
||
173 | if (aBeast == beastName) then |
||
174 | foundBeast = true; |
||
175 | end |
||
176 | end |
||
177 | end |
||
178 | if (not foundBeast) then |
||
179 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." not found in FHH_SpellInfo for spell "..GFWUtils.Hilite(niceSpellName).."."); |
||
180 | errorCount = errorCount + 1; |
||
181 | end |
||
182 | end |
||
183 | end |
||
184 | end |
||
185 | end |
||
186 | if (errorCount == 0) then |
||
187 | GFWUtils.Print("Test 5 passed; all appropriate info from FHH_BeastInfo is mirrored in FHH_SpellInfo."); |
||
188 | end |
||
189 | return errorCount; |
||
190 | end |
||
191 | |||
192 | function FHH_Test6() |
||
193 | -- 6: make sure every beast listed in FHH_BeastInfo is in FHH_BeastLevels and vice versa |
||
194 | local errorCount = 0; |
||
195 | for beastName in FHH_BeastInfo do |
||
196 | if (FHH_BeastLevels[beastName] == nil) then |
||
197 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." is in FHH_BeastInfo but not FHH_BeastLevels."); |
||
198 | errorCount = errorCount + 1; |
||
199 | end |
||
200 | end |
||
201 | for beastName in FHH_BeastLevels do |
||
202 | if (FHH_BeastInfo[beastName] == nil) then |
||
203 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." is in FHH_BeastLevels but not FHH_BeastInfo."); |
||
204 | errorCount = errorCount + 1; |
||
205 | end |
||
206 | end |
||
207 | |||
208 | if (errorCount == 0) then |
||
209 | GFWUtils.Print("Test 6 passed; beast-indexed tables (FHH_BeastInfo and FHH_BeastLevels) match all indices."); |
||
210 | end |
||
211 | return errorCount; |
||
212 | end |
||
213 | |||
214 | function FHH_Test7() |
||
215 | -- 7: make sure every beast in FHH_BeastLevels is listed in FHH_SpellInfo |
||
216 | local errorCount = 0; |
||
217 | for beastName in FHH_BeastLevels do |
||
218 | local foundBeast = false; |
||
219 | for spellID, ranksTable in FHH_SpellInfo do |
||
220 | if (type(ranksTable) == "table") then |
||
221 | for rankNum, zonesTable in ranksTable do |
||
222 | for zoneName, beastsTable in zonesTable do |
||
223 | for _, aBeast in beastsTable do |
||
224 | if (aBeast == beastName) then |
||
225 | foundBeast = true; |
||
226 | end |
||
227 | end |
||
228 | end |
||
229 | end |
||
230 | end |
||
231 | end |
||
232 | if (not foundBeast) then |
||
233 | GFWUtils.Print(GFWUtils.Red("Hunter's Helper Error: ")..GFWUtils.Hilite(beastName).." is in FHH_BeastLevels but not FHH_SpellInfo."); |
||
234 | errorCount = errorCount + 1; |
||
235 | end |
||
236 | end |
||
237 | |||
238 | if (errorCount == 0) then |
||
239 | GFWUtils.Print("Test 7 passed; every beast in FHH_BeastLevels is listed in FHH_SpellInfo."); |
||
240 | end |
||
241 | return errorCount; |
||
242 | end |