@@ -15,6 +15,17 @@ describe("TradeQueryGenerator", function()
1515 end )
1616
1717 describe (" WeightedRatioOutputs" , function ()
18+ local maxStatIncrease
19+
20+ before_each (function ()
21+ maxStatIncrease = data .misc .maxStatIncrease
22+ data .misc .maxStatIncrease = 1000
23+ end )
24+
25+ after_each (function ()
26+ data .misc .maxStatIncrease = maxStatIncrease
27+ end )
28+
1829 -- Pass: Returns 0, avoiding math errors
1930 -- Fail: Returns NaN/inf or crashes, indicating unhandled infinite values, causing evaluation failures in infinite-scaling builds
2031 it (" handles infinite base" , function ()
@@ -31,10 +42,63 @@ describe("TradeQueryGenerator", function()
3142 local baseOutput = { TotalDPS = 0 }
3243 local newOutput = { TotalDPS = 100 }
3344 local statWeights = { { stat = " TotalDPS" , weightMult = 1 } }
34- data .misc .maxStatIncrease = 1000
3545 local result = mock_queryGen .WeightedRatioOutputs (baseOutput , newOutput , statWeights )
3646 assert .are .equal (result , 100 )
3747 end )
48+ it (" uses minion output for non-FullDPS stats when minion output is desired" , function ()
49+ local baseOutput = { Life = 10 , Minion = { Life = 100 } }
50+ local newOutput = { Life = 10 , Minion = { Life = 250 } }
51+ local statWeights = { { stat = " MinionLife" , weightMult = 1 } }
52+ local result = mock_queryGen .WeightedRatioOutputs (baseOutput , newOutput , statWeights )
53+
54+ assert .are .equal (result , 2.5 )
55+ end )
56+
57+ it (" uses lower is better stats correctly" , function ()
58+ local baseOutput = { MaxHit = 100 }
59+ local newOutput = { MaxHit = 10 }
60+ local statWeights = { { stat = " MaxHit" , weightMult = 1 , transform = function (number ) return - number end } }
61+ local result = mock_queryGen .WeightedRatioOutputs (baseOutput , newOutput , statWeights )
62+
63+ local close_enough = math.abs (result - - 0.1 ) < 0.0001
64+ assert .True (close_enough )
65+ end )
66+
67+ it (" uses player and minion output for FullDPS" , function ()
68+ -- minion output gets assigned to the player's full dps in reality
69+ local baseOutput = { FullDPS = 100 , Minion = { FullDPS = 100 } }
70+ local newOutput = { FullDPS = 250 , Minion = { FullDPS = 1000 } }
71+ local statWeights = { { stat = " FullDPS" , weightMult = 1 } }
72+ local result = mock_queryGen .WeightedRatioOutputs (baseOutput , newOutput , statWeights )
73+
74+ assert .are .equal (result , 2.5 )
75+ end )
76+
77+ it (" uses player output for non-FullDPS even when minion output is available" , function ()
78+ local baseOutput = { Life = 100 , Minion = { Life = 100 } }
79+ local newOutput = { Life = 250 , Minion = { Life = 1000 } }
80+ local statWeights = { { stat = " Life" , weightMult = 1 } }
81+ local result = mock_queryGen .WeightedRatioOutputs (baseOutput , newOutput , statWeights )
82+ assert .are .equal (result , 2.5 )
83+ end )
84+
85+ it (" uses the fallback DPS ratio once when FullDPS is unavailable" , function ()
86+ local baseOutput = { Minion = { TotalDPS = 10 , TotalDotDPS = 0 , CombinedDPS = 10 } }
87+ local newOutput = { Minion = { TotalDPS = 25 , TotalDotDPS = 0 , CombinedDPS = 25 } }
88+ local statWeights = { { stat = " FullDPS" , weightMult = 1 } }
89+ local result = mock_queryGen .WeightedRatioOutputs (baseOutput , newOutput , statWeights )
90+
91+ assert .are .equal (result , 2.5 )
92+ end )
93+
94+ it (" falls back to player output when the selected stat is not on minion output" , function ()
95+ local baseOutput = { Spirit = 100 , Minion = { AverageDamage = 100 } }
96+ local newOutput = { Spirit = 120 , Minion = { AverageDamage = 100 } }
97+ local statWeights = { { stat = " Spirit" , weightMult = 1 } }
98+ local result = mock_queryGen .WeightedRatioOutputs (baseOutput , newOutput , statWeights )
99+
100+ assert .are .equal (result , 1.2 )
101+ end )
38102 end )
39103
40104 describe (" Filter prioritization" , function ()
0 commit comments