summaryrefslogtreecommitdiffstats
path: root/test/lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/lua/acme_file.lua4
-rw-r--r--test/lua/inspect.lua5
-rw-r--r--test/lua/proto.lua8
-rw-r--r--test/lua/verify_globals.lua15
4 files changed, 28 insertions, 4 deletions
diff --git a/test/lua/acme_file.lua b/test/lua/acme_file.lua
index f159ba2d..59c48dc6 100644
--- a/test/lua/acme_file.lua
+++ b/test/lua/acme_file.lua
@@ -438,7 +438,9 @@ function State:get_timestamp(line, file_position, seeking)
self.nstime = NSTime(timet, milli * 1000000)
self.packets[file_position][TTIME] = self.nstime
- timet = timet + (milli/1000)
+ -- For Lua 5.3 and later, make sure we have an integer via a method
+ -- that also works on Lua 5.1. (os.date doesn't handle fractional seconds.)
+ timet = timet + math.floor(milli/1000)
dprint2("found time of ", os.date("%c",timet), " with value=",timet)
return self.nstime, line_pos
diff --git a/test/lua/inspect.lua b/test/lua/inspect.lua
index 6b4aff9c..2d967128 100644
--- a/test/lua/inspect.lua
+++ b/test/lua/inspect.lua
@@ -416,7 +416,10 @@ function inspect.marshal(inString, options)
inString = "return " .. inString
end
- local t = assert(loadstring(inString))()
+ -- loadstring was removed after Lua 5.1, load given a string
+ -- argument does the same thing
+ local load = (_VERSION == "Lua 5.1") and loadstring or load
+ local t = assert(load(inString))()
removeIndex(t)
diff --git a/test/lua/proto.lua b/test/lua/proto.lua
index cc038989..b4306c69 100644
--- a/test/lua/proto.lua
+++ b/test/lua/proto.lua
@@ -9,8 +9,9 @@ local testlib = require("testlib")
local OTHER = "other"
-- expected number of runs per type
+-- # of fields test doesn't work on Lua 5.4
local taptests = {
- [OTHER]=48
+ [OTHER]=47
}
testlib.init(taptests)
@@ -156,7 +157,10 @@ local myfields = { pf_trasaction_id, pf_flags,
--dns.fields = myfields
testlib.test(OTHER,"Proto.fields-set", pcall(setValue,dns,"fields",myfields))
testlib.test(OTHER,"Proto.fields-get", pcall(getValue,dns,"fields"))
-testlib.test(OTHER,"Proto.fields-get", #dns.fields == #myfields)
+-- This test doesn't work on Lua 5.4 because the # operator includes the
+-- reference(s) that are the linked list of allocated and free keys,
+-- starting with LUA_RIDX_LAST + 1 == 3.
+-- testlib.test(OTHER,"Proto.fields-get", #dns.fields == #myfields)
local pf_foo = ProtoField.uint16("myfoo.com", "Fooishly", base.DEC, rcodes, 0x000F)
diff --git a/test/lua/verify_globals.lua b/test/lua/verify_globals.lua
index dbed8ceb..5e61ffce 100644
--- a/test/lua/verify_globals.lua
+++ b/test/lua/verify_globals.lua
@@ -35,13 +35,20 @@ local ignore = {
"getfenv",
"io.gfind",
"setfenv",
+ "loadstring", -- call load with a string argument
+ "math.log10", -- call math.log with second argument
"math.mod",
+ "module",
"newproxy",
+ "package.loaders", -- renamed package.searchers
+ "package.seeall", -- used with module
"string.gfind",
"table.foreach",
"table.foreachi",
"table.getn",
+ "table.maxn",
"table.setn",
+ "unpack", -- replaced by table.unpack
-- in Lua 5.2+ only
"bit32",
@@ -55,6 +62,14 @@ local ignore = {
"table.pack",
"table.unpack",
+ -- removed in Lua 5.3
+ "math.atan2", -- use math.atan with two arguments
+ "math.cosh",
+ "math.sinh",
+ "math.tanh",
+ "math.pow", -- use x^y
+ "math.frexp",
+ "math.ldexp", -- use x * 2.0^exp
}