github.com/coinstack/gopher-lua@v0.0.0-20180626044619-c9c62d4ee45e/_glua-tests/coroutine.lua (about)

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