2014-10-07 05:06:06 +00:00
|
|
|
require "defaults"
|
2015-03-21 09:02:25 +00:00
|
|
|
package.path = "?.lua;common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" .. package.path
|
|
|
|
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" .. package.cpath
|
2014-10-07 05:06:06 +00:00
|
|
|
|
|
|
|
-- global reader settings
|
|
|
|
local DocSettings = require("docsettings")
|
|
|
|
G_reader_settings = DocSettings:open(".reader")
|
|
|
|
|
|
|
|
-- global einkfb for Screen (do not show SDL window)
|
|
|
|
einkfb = require("ffi/framebuffer")
|
|
|
|
einkfb.dummy = true
|
|
|
|
|
|
|
|
-- init output device
|
2014-10-30 18:42:18 +00:00
|
|
|
local Screen = require("device").screen
|
2014-10-07 05:06:06 +00:00
|
|
|
Screen:init()
|
|
|
|
|
|
|
|
-- init input device (do not show SDL window)
|
2014-10-30 18:42:18 +00:00
|
|
|
local Input = require("device").input
|
2014-10-07 05:06:06 +00:00
|
|
|
Input.dummy = true
|
|
|
|
|
|
|
|
-- turn on debug
|
|
|
|
local DEBUG = require("dbg")
|
2014-11-27 02:45:46 +00:00
|
|
|
--DEBUG:turnOn()
|
2015-10-07 14:42:12 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|