Skip to content

Commit

Permalink
Add yieldable test
Browse files Browse the repository at this point in the history
  • Loading branch information
CannibalVox committed Apr 11, 2020
1 parent 756dd57 commit 59a6462
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lua_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ func TestInitGlobal(t *testing.T) {
require.Equal(t, 0, outlyingAllocs())
}

func TestIsYieldable(t *testing.T) {
clearAllocs()
vm := NewState()
defer closeVM(t, vm)

err := vm.DoString(`
function canyield()
return coroutine.isyieldable()
end
`)
require.Nil(t, err)

funcObj, err := vm.GetGlobal("canyield")
require.Nil(t, err)
f := funcObj.(*LocalLuaFunction)
outVal, err := f.Call()
require.Nil(t, err)
require.Equal(t, false, outVal[0])

err = f.Close()
require.Nil(t, err)

require.Equal(t, 0, outlyingAllocs())
}

func TestInitGlobalNumIndex(t *testing.T) {
clearAllocs()
vm := NewState()
Expand Down

0 comments on commit 59a6462

Please sign in to comment.