aboutsummaryrefslogtreecommitdiff
path: root/testes/coroutine.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/coroutine.lua')
-rw-r--r--testes/coroutine.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua
index 5b927151..aaf565fb 100644
--- a/testes/coroutine.lua
+++ b/testes/coroutine.lua
@@ -134,7 +134,8 @@ do
134 local co = coroutine.create(print) 134 local co = coroutine.create(print)
135 assert(coroutine.resume(co, "testing 'coroutine.close'")) 135 assert(coroutine.resume(co, "testing 'coroutine.close'"))
136 assert(coroutine.status(co) == "dead") 136 assert(coroutine.status(co) == "dead")
137 assert(coroutine.close(co)) 137 local st, msg = coroutine.close(co)
138 assert(st and msg == nil)
138 139
139 -- cannot close the running coroutine 140 -- cannot close the running coroutine
140 local st, msg = pcall(coroutine.close, coroutine.running()) 141 local st, msg = pcall(coroutine.close, coroutine.running())
@@ -151,6 +152,13 @@ do
151 -- to-be-closed variables in coroutines 152 -- to-be-closed variables in coroutines
152 local X 153 local X
153 154
155 -- closing a coroutine after an error
156 local co = coroutine.create(error)
157 local st, msg = coroutine.resume(co, 100)
158 assert(not st and msg == 100)
159 st, msg = coroutine.close(co)
160 assert(not st and msg == 100)
161
154 co = coroutine.create(function () 162 co = coroutine.create(function ()
155 local x <close> = func2close(function (self, err) 163 local x <close> = func2close(function (self, err)
156 assert(err == nil); X = false 164 assert(err == nil); X = false