mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
35 lines
899 B
Text
35 lines
899 B
Text
|
-- Delayed functions should never run right away
|
||
|
|
||
|
local flag: boolean = false
|
||
|
task.delay(0, function()
|
||
|
flag = true
|
||
|
end)
|
||
|
assert(not flag, "Delay should never run instantly")
|
||
|
|
||
|
-- Delayed functions should work with yielding
|
||
|
|
||
|
local flag2: boolean = false
|
||
|
task.delay(0.2, function()
|
||
|
flag2 = true
|
||
|
task.wait(0.2)
|
||
|
flag2 = false
|
||
|
end)
|
||
|
task.wait(0.25)
|
||
|
assert(flag2, "Delay should work with yielding")
|
||
|
task.wait(0.25)
|
||
|
assert(not flag2, "Delay should work with yielding")
|
||
|
|
||
|
-- Varargs should get passed correctly
|
||
|
|
||
|
local function f(arg1: string, arg2: number, f2: (...any) -> ...any)
|
||
|
assert(type(arg1) == "string", "Invalid arg 1 passed to function")
|
||
|
assert(type(arg2) == "number", "Invalid arg 2 passed to function")
|
||
|
assert(type(arg3) == "function", "Invalid arg 3 passed to function")
|
||
|
end
|
||
|
|
||
|
task.delay(0, f, "", 1, f)
|
||
|
task.delay(0, f, "inf", math.huge, f)
|
||
|
task.delay(0, f, "NaN", 0 / 0, f)
|
||
|
|
||
|
task.wait(0.1)
|