[spec] Replace custom assert[Not]AlmostEquals with assert.is[_not].near (#3885)

Also, change "make static-check" to also check the tests.
This commit is contained in:
Frode Austvik
2018-04-15 23:49:08 +02:00
committed by Frans de Jonge
parent 88dee4194d
commit f12f317e9d
5 changed files with 11 additions and 39 deletions

View File

@@ -24,32 +24,6 @@ Screen:init()
local Input = require("device").input
Input.dummy = true
function assertAlmostEquals(expected, actual, margin)
if type(actual) ~= 'number' or type(expected) ~= 'number'
or type(margin) ~= 'number' then
error('assertAlmostEquals: must supply only number arguments.', 2)
end
assert(math.abs(expected - actual) <= margin,
'Values are not almost equal\n'
.. 'Expected: ' .. expected .. ' with margin of ' .. margin
.. ', received: ' .. actual
)
end
function assertNotAlmostEquals(expected, actual, margin)
if type(actual) ~= 'number' or type(expected) ~= 'number'
or type(margin) ~= 'number' then
error('assertAlmostEquals: must supply only number arguments.', 2)
end
assert(math.abs(expected - actual) > margin,
'Values are almost equal\n'
.. 'Expected: ' .. expected .. ' with margin of ' .. margin
.. ', received: ' .. actual
)
end
package.unload = function(module)
if type(module) ~= "string" then return false end
package.loaded[module] = nil