Fix coroutine error handling.

This commit is contained in:
James Roseborough
2008-07-24 03:13:50 +00:00
parent 4fcb2b1796
commit 1170b5822f
3 changed files with 17 additions and 9 deletions

View File

@@ -46,7 +46,9 @@ exercise();
co = coroutine.create(function (a,b)
print("co-body", a, b)
local status,r = pcall( foo, a+1 )
-- TODO: make java and C behave the same for yielding in pcalls
-- local status,r = pcall( foo, a+1 )
foo(a+1)
print("co-body", status,r)
local r, s = coroutine.yield(a+b, a-b)
print("co-body", r, s)
@@ -69,5 +71,6 @@ end )
print("g", g(1, 10))
print("g", g("r"))
print("g", g("x", "y"))
print("g", pcall( g, "x", "y" ))
local s,e = pcall( g, "x", "y" )
print("g", string.match(e,'cannot resume dead coroutine') or 'badmessage: '..tostring(e))