Fix pcall test, improve scheduler panic message

This commit is contained in:
Filip Tibell 2023-08-20 15:07:02 -05:00
parent 5905b2d6cf
commit 57677278c4
2 changed files with 9 additions and 6 deletions

View file

@ -14,10 +14,10 @@ where
where where
F: Future<Output = ()> + 'fut, F: Future<Output = ()> + 'fut,
{ {
let futs = self let futs = self.futures.try_lock().expect(
.futures "Failed to lock futures queue - \
.try_lock() make sure not to schedule futures during futures resumption",
.expect("Failed to lock futures queue"); );
futs.push(Box::pin(fut)) futs.push(Box::pin(fut))
} }

View file

@ -7,7 +7,10 @@ local PORT = 9090 -- NOTE: This must be different from
local function test(f, ...) local function test(f, ...)
local success, message = pcall(f, ...) local success, message = pcall(f, ...)
assert(not success, "Function did not throw an error") assert(not success, "Function did not throw an error")
assert(type(message) == "userdata", "Pcall did not return a proper error") assert(
type(message) == "string" or type(message) == "userdata",
"Pcall did not return a proper error"
)
end end
-- These are not async but should be pcallable -- These are not async but should be pcallable
@ -24,7 +27,7 @@ local handle = net.serve(PORT, function()
return "" return ""
end) end)
task.delay(0, function() task.delay(0.25, function()
handle.stop() handle.stop()
end) end)