Ensure threads get returned from task lib in unit tests

This commit is contained in:
Filip Tibell 2023-01-22 17:06:35 -05:00
parent f22ef577cf
commit 276200225b
No known key found for this signature in database
3 changed files with 15 additions and 0 deletions

View file

@ -1,3 +1,8 @@
-- Deferring a task should return the thread that can then be cancelled
local thread = task.defer(function() end)
assert(type(thread) == "thread", "Defer should return the thread spawned")
-- Deferred functions should run after other threads
local flag: boolean = false

View file

@ -1,3 +1,8 @@
-- Delaying a task should return the thread that can then be cancelled
local thread = task.delay(0, function() end)
assert(type(thread) == "thread", "Delay should return the thread spawned")
-- Delayed functions should never run right away
local flag: boolean = false

View file

@ -1,3 +1,8 @@
-- Spawning a task should return the thread that can then be cancelled
local thread = task.spawn(function() end)
assert(type(thread) == "thread", "Spawn should return the thread spawned")
-- Spawned functions should run right away
local flag: boolean = false