Browse Source

[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".
pull/5783/head
Vsevolod Stakhov 2 weeks ago
parent
commit
b4ed7bffe6
No known key found for this signature in database GPG Key ID: 7647B6790081437
  1. 6
      test/functional/lua/limits.lua

6
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
Loading…
Cancel
Save