From: Vsevolod Stakhov Date: Sat, 6 Dec 2025 13:42:00 +0000 (+0000) Subject: [Fix] Use math.floor for Lua 5.4 integer division compatibility X-Git-Tag: 3.14.2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4ed7bffe681162fcef340f3c90e3ba006f1992c;p=thirdparty%2Frspamd.git [Fix] Use math.floor for Lua 5.4 integer division compatibility In Lua 5.4, the / operator always returns a float (2/2 = 1.0), while LuaJIT returns an integer (2/2 = 1). This caused test dependency registration to fail as tostring(i/2) produced "1.0" instead of "1". --- diff --git a/test/functional/lua/limits.lua b/test/functional/lua/limits.lua index 52fb47fb9e..e6bb2ce20e 100644 --- a/test/functional/lua/limits.lua +++ b/test/functional/lua/limits.lua @@ -9,13 +9,15 @@ for _, i in ipairs(test_weights) do rspamd_config:register_symbol('GR_POSITIVE' .. tostring(i), 1.0, true_cb_gen()) if i > 1 then - rspamd_config:register_dependency('GR_POSITIVE' .. tostring(i), 'GR_POSITIVE' .. tostring(i / 2)) + local half = math.floor(i / 2) + rspamd_config:register_dependency('GR_POSITIVE' .. tostring(i), 'GR_POSITIVE' .. tostring(half)) end rspamd_config:register_symbol('GR_NEGATIVE' .. tostring(i), 1.0, true_cb_gen()) if i > 1 then - rspamd_config:register_dependency('GR_NEGATIVE' .. tostring(i), 'GR_NEGATIVE' .. tostring(i / 2)) + local half = math.floor(i / 2) + rspamd_config:register_dependency('GR_NEGATIVE' .. tostring(i), 'GR_NEGATIVE' .. tostring(half)) end end