diff options
Diffstat (limited to '')
-rw-r--r-- | testes/coroutine.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index ca30011f..a4321bed 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -142,8 +142,15 @@ do | |||
142 | 142 | ||
143 | -- to-be-closed variables in coroutines | 143 | -- to-be-closed variables in coroutines |
144 | local X | 144 | local X |
145 | |||
146 | local function func2close (f) | ||
147 | return setmetatable({}, {__close = f}) | ||
148 | end | ||
149 | |||
145 | co = coroutine.create(function () | 150 | co = coroutine.create(function () |
146 | local *toclose x = function (err) assert(err == nil); X = false end | 151 | local *toclose x = func2close(function (self, err) |
152 | assert(err == nil); X = false | ||
153 | end) | ||
147 | X = true | 154 | X = true |
148 | coroutine.yield() | 155 | coroutine.yield() |
149 | end) | 156 | end) |
@@ -154,7 +161,9 @@ do | |||
154 | 161 | ||
155 | -- error killing a coroutine | 162 | -- error killing a coroutine |
156 | co = coroutine.create(function() | 163 | co = coroutine.create(function() |
157 | local *toclose x = function (err) assert(err == nil); error(111) end | 164 | local *toclose x = func2close(function (self, err) |
165 | assert(err == nil); error(111) | ||
166 | end) | ||
158 | coroutine.yield() | 167 | coroutine.yield() |
159 | end) | 168 | end) |
160 | coroutine.resume(co) | 169 | coroutine.resume(co) |