Skip to content

Commit 5ac345f

Browse files
committed
tests/lapi: update assertions in os tests
The patch updates assertions for values returned by `os.date()` and `os.time()`, LuaJIT-specific type checks moved under condition.
1 parent 68047ba commit 5ac345f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

tests/lapi/os_date_test.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ local function TestOneInput(buf)
3232
local err_handler = test_lib.err_handler(ignored_msgs)
3333
local ok, res = xpcall(os.date, err_handler, format, time)
3434
if not ok then return end
35-
assert(type(res) == "string" or
36-
type(res) == "table" or
37-
-- Undocumented.
35+
local type_check = type(res) == "string" or type(res) == "table"
36+
if test_lib.lua_version() ~= "LuaJIT" then
37+
assert(type_check)
38+
end
39+
assert(type_check or
40+
-- LuaJIT-specific type checks.
3841
type(res) == "number" or
3942
res == nil)
4043
end

tests/lapi/os_time_test.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ local function TestOneInput(buf)
3232
local err_handler = test_lib.err_handler(ignored_msgs)
3333
local ok, res = xpcall(os.time, err_handler, time)
3434
if not ok then return end
35-
io.stderr:write(type(res) .. "\n")
36-
assert(type(res) == "number" or
37-
type(res) == "table" or
38-
-- Undocumented.
35+
local type_check = type(res) == "number" or type(res) == "table"
36+
if test_lib.lua_version() ~= "LuaJIT" then
37+
assert(type_check)
38+
end
39+
assert(type_check or
40+
-- LuaJIT-specific type checks.
3941
res == nil)
4042
end
4143

0 commit comments

Comments
 (0)