SinisterRectus / Discordia

Discord API library written in Lua for the Luvit runtime environment
MIT License
697 stars 143 forks source link

dev branch: date overflow in test-date #333

Open Bilal2453 opened 2 years ago

Bilal2453 commented 2 years ago

Running the tests yields the following error:

Uncaught exception:
...e/Dev/Luvit/discordia/discordia-fork/tests/test-date.lua:179: expected: "date could not be converted to time", received: "...l/home/Dev/Luvit/discordia/discordia-fork/libs/class.lua:16: expected minimum 0, received -31536000"
stack traceback:
    [C]: in function 'assertError'
    ...e/Dev/Luvit/discordia/discordia-fork/tests/test-date.lua:179: in function 'fn'
    [string "bundle:deps/require.lua"]:310: in function 'require'
    ...al/home/Dev/Luvit/discordia/discordia-fork/tests/run.lua:11: in function 'fn'
    [string "bundle:deps/require.lua"]:310: in function 'require'
    [string "bundle:/main.lua"]:128: in function <[string "bundle:/main.lua"]:20>
stack traceback:
    [C]: in function 'error'
    [string "bundle:/deps/utils.lua"]:41: in function 'assertResume'
    [string "bundle:/init.lua"]:52: in function <[string "bundle:/init.lua"]:47>
    [C]: in function 'xpcall'
    [string "bundle:/init.lua"]:47: in function 'fn'
    [string "bundle:deps/require.lua"]:310: in function <[string "bundle:deps/require.lua"]:266>

The system's clock is GMT+3.

Traced the error a bit, here os.time overflows returning a value of -31546800, here it seems like it fails to normalize it to 0 (if that was suppose to happen, don't seem it is) and here the error is raised.

Now the value passed in the test is 1969, so I suppose it is meant to raise this error? It is really expected to overflow in this case, so I guess the bug here is just the assertError call used. Edit: At least what I assume, all of this is based on assumptions since I am not entirely sure what is the supposed behavior.