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
F: Future<Output = ()> + 'fut,
{
let futs = self
.futures
.try_lock()
.expect("Failed to lock futures queue");
let futs = self.futures.try_lock().expect(
"Failed to lock futures queue - \
make sure not to schedule futures during futures resumption",
);
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 success, message = pcall(f, ...)
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
-- These are not async but should be pcallable
@ -24,7 +27,7 @@ local handle = net.serve(PORT, function()
return ""
end)
task.delay(0, function()
task.delay(0.25, function()
handle.stop()
end)