mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 16:53:46 +01:00
Lua log files: Fix infinities
This commit is contained in:
parent
95e4caa2f8
commit
44ad494d99
@ -13,7 +13,8 @@ end
|
|||||||
function lua_log_file:load()
|
function lua_log_file:load()
|
||||||
-- Bytecode is blocked by the engine
|
-- Bytecode is blocked by the engine
|
||||||
local read = assert(loadfile(self.file_path))
|
local read = assert(loadfile(self.file_path))
|
||||||
local env = {}
|
-- math.huge is serialized to inf
|
||||||
|
local env = {inf = math.huge}
|
||||||
setfenv(read, env)
|
setfenv(read, env)
|
||||||
read()
|
read()
|
||||||
env.R = env.R or {{}}
|
env.R = env.R or {{}}
|
||||||
|
4
test.lua
4
test.lua
@ -196,10 +196,10 @@ local logfile = persistence.lua_log_file.new(mod.get_resource"logfile.test.lua",
|
|||||||
logfile:init()
|
logfile:init()
|
||||||
logfile.root = {}
|
logfile.root = {}
|
||||||
logfile:rewrite()
|
logfile:rewrite()
|
||||||
logfile:set_root({a = 1}, {b = 2, c = 3})
|
logfile:set_root({a = 1}, {b = 2, c = 3, d = _G.math.huge, e = -_G.math.huge})
|
||||||
logfile:close()
|
logfile:close()
|
||||||
logfile:init()
|
logfile:init()
|
||||||
assert(table.equals(logfile.root, {[{a = 1}] = {b = 2, c = 3}}))
|
assert(table.equals(logfile.root, {[{a = 1}] = {b = 2, c = 3, d = _G.math.huge, e = -_G.math.huge}}))
|
||||||
|
|
||||||
-- in-game tests & b3d testing
|
-- in-game tests & b3d testing
|
||||||
local tests = {
|
local tests = {
|
||||||
|
Loading…
Reference in New Issue
Block a user