From 46c1dcd21f680f5c72951ea020d66362104bddb1 Mon Sep 17 00:00:00 2001 From: Rerumu Date: Wed, 15 Jun 2022 20:57:14 -0400 Subject: [PATCH] Make test number comparisons real fuzzy --- dev-test/tests/assertion.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-test/tests/assertion.lua b/dev-test/tests/assertion.lua index 655c0f2..5a0b1aa 100644 --- a/dev-test/tests/assertion.lua +++ b/dev-test/tests/assertion.lua @@ -10,10 +10,10 @@ local function is_number_equality(lhs, rhs) if type(lhs) ~= "number" or type(rhs) ~= "number" then return false elseif lhs ~= lhs and rhs ~= rhs then - return lhs ~= rhs + return true 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 local function assert_eq(lhs, rhs, message, level)