github.com/hirochachacha/plua@v0.0.0-20170217012138-c82f520cc725/stdlib/coroutine/coroutine_test.go (about) 1 package coroutine_test 2 3 import ( 4 "path/filepath" 5 "testing" 6 7 "github.com/hirochachacha/plua/compiler" 8 "github.com/hirochachacha/plua/runtime" 9 "github.com/hirochachacha/plua/stdlib/base" 10 "github.com/hirochachacha/plua/stdlib/coroutine" 11 "github.com/hirochachacha/plua/stdlib/debug" 12 ) 13 14 func TestCoroutine(t *testing.T) { 15 c := compiler.NewCompiler() 16 17 matches, err := filepath.Glob("testdata/*.lua") 18 if err != nil { 19 t.Fatal(err) 20 } 21 22 for _, fname := range matches { 23 proto, err := c.CompileFile(fname, 0) 24 if err != nil { 25 t.Fatal(err) 26 } 27 28 p := runtime.NewProcess() 29 30 p.Require("_G", base.Open) 31 p.Require("debug", debug.Open) 32 p.Require("coroutine", coroutine.Open) 33 34 _, err = p.Exec(proto) 35 if err != nil { 36 t.Error(err) 37 } 38 } 39 }