Skip to content

Commit 42fa96a

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 42fa96a

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

tests/lapi/os_date_test.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +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.
38-
type(res) == "number" or
39-
res == nil)
35+
local type_check = type(res) == "string" or type(res) == "table"
36+
if test_lib.lua_version() == "LuaJIT" then
37+
assert(type_check or type(res) == "number" or res == nil)
38+
else
39+
assert(type_check)
40+
end
4041
end
4142

4243
local args = {

tests/lapi/os_time_test.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +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.
39-
res == nil)
35+
local type_check = type(res) == "number" or type(res) == "table"
36+
if test_lib.lua_version() == "LuaJIT" then
37+
assert(type_check or res == nil)
38+
else
39+
assert(type_check)
40+
end
4041
end
4142

4243
local args = {

0 commit comments

Comments
 (0)