coroutine.lua 339 B

1234567891011121314151617
  1. co = coroutine.wrap(function()
  2. co()
  3. end)
  4. local ok, msg = pcall(function()
  5. co()
  6. end)
  7. assert(not ok and string.find(msg, "can not resume a running thread"))
  8. co = coroutine.wrap(function()
  9. return 1
  10. end)
  11. assert(co() == 1)
  12. local ok, msg = pcall(function()
  13. co()
  14. end)
  15. assert(not ok and string.find(msg, "can not resume a dead thread"))