Make test number comparisons real fuzzy

This commit is contained in:
Rerumu 2022-06-15 20:57:14 -04:00
parent 65cd89c6d7
commit 46c1dcd21f

View File

@ -10,10 +10,10 @@ local function is_number_equality(lhs, rhs)
if type(lhs) ~= "number" or type(rhs) ~= "number" then if type(lhs) ~= "number" or type(rhs) ~= "number" then
return false return false
elseif lhs ~= lhs and rhs ~= rhs then elseif lhs ~= lhs and rhs ~= rhs then
return lhs ~= rhs return true
end end
return math.abs(lhs - rhs) < 0.000001 return math.abs(lhs - rhs) < 0.00001 or string.format("%.3g", lhs) == string.format("%.3g", rhs)
end end
local function assert_eq(lhs, rhs, message, level) local function assert_eq(lhs, rhs, message, level)