mirror of
https://github.com/centau/vide.git
synced 2026-10-24 06:41:38 +00:00
Fix scope stack staying broken after a yield in strict mode (#105)
Some checks failed
unit-test / unit-test (push) Has been cancelled
Some checks failed
unit-test / unit-test (push) Has been cancelled
* Fix scope stack staying broken after a yield in strict mode * Warn on a yield in strict mode instead of cancelling the thread * Fix type error when an effect errors outside strict mode
This commit is contained in:
parent
d99dbe1873
commit
033d30fbfb
3 changed files with 51 additions and 12 deletions
|
|
@ -3146,7 +3146,7 @@ end))
|
|||
TEST("strict", wrap_root(function()
|
||||
vide.strict = true
|
||||
|
||||
do CASE "error on derived callback yield"
|
||||
do CASE "warn on derived callback yield"
|
||||
local src = source(1)
|
||||
|
||||
local ok = pcall(function()
|
||||
|
|
@ -3156,10 +3156,10 @@ TEST("strict", wrap_root(function()
|
|||
end)
|
||||
end)
|
||||
|
||||
CHECK(not ok)
|
||||
CHECK(ok)
|
||||
end
|
||||
|
||||
do CASE "error on effecter callback yield"
|
||||
do CASE "warn on effecter callback yield"
|
||||
local src = source(1)
|
||||
|
||||
local ok = pcall(function()
|
||||
|
|
@ -3169,7 +3169,28 @@ TEST("strict", wrap_root(function()
|
|||
end)
|
||||
end)
|
||||
|
||||
CHECK(not ok)
|
||||
CHECK(ok)
|
||||
end
|
||||
|
||||
do CASE "yield in a component"
|
||||
local input = source(false)
|
||||
local thread
|
||||
local output
|
||||
|
||||
local destroy = root(function()
|
||||
output = show(input, function()
|
||||
thread = coroutine.running()
|
||||
coroutine.yield()
|
||||
return "component"
|
||||
end)
|
||||
end)
|
||||
|
||||
CHECK((pcall(input, true)))
|
||||
CHECK(output() == nil)
|
||||
CHECK((coroutine.resume(thread)))
|
||||
CHECK(output() == "component")
|
||||
CHECK(pcall(input, false))
|
||||
CHECK(pcall(destroy))
|
||||
end
|
||||
|
||||
do CASE "run derived callback twice"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue