Skip to content

Commit 41cd3d1

Browse files
committed
tests/lapi: fix assertion with result in os_time_test
The `mktime()` function (which is used inside `os.time()`) returns -1 for cases when the time since the Epoch cannot be represented. In this case, `os.time()` returns `nil`: ``` luajit -e "print(os.time({year = 1970, month = 1, day = 1, sec = -9 * 60 * 60 - 1}))" nil ``` The patch fixes an assertion in the test and allows `nil` as a result of the function. Follows up #141
1 parent de2f1ab commit 41cd3d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/lapi/os_time_test.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ 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-
assert(type(res) == "number" or type(res) == "table")
35+
io.stderr:write(type(res) .. "\n")
36+
assert(type(res) == "number" or
37+
type(res) == "table" or
38+
-- Undocumented.
39+
res == nil)
3640
end
3741

3842
local args = {

0 commit comments

Comments
 (0)