mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[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:
committed by
Frans de Jonge
parent
88dee4194d
commit
f12f317e9d
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user