github.com/dfklegend/cell2/utils@v0.0.0-20240402033734-a0a9f3d9335d/golua/golua_test.go (about) 1 package golua 2 3 import ( 4 "fmt" 5 "os" 6 "testing" 7 ) 8 9 var gluaTests = []string{ 10 "base", 11 "coroutine", 12 "db", 13 "issues", 14 "os", 15 "table", 16 "vm", 17 "math", 18 "strings", 19 "goto", 20 } 21 22 func testScriptDir(t *testing.T, tests []string, directory string) { 23 if err := os.Chdir(directory); err != nil { 24 t.Error(err) 25 } 26 defer os.Chdir("..") 27 28 luaEngine := NewLuaEngine() 29 defer luaEngine.Close() 30 31 for _, script := range tests { 32 fmt.Printf("testing %s/%s\n", directory, script) 33 if err := luaEngine.DoLuaFile(fmt.Sprintf("%s.lua", script)); err != nil { 34 t.Error(err) 35 } 36 } 37 } 38 39 var numActiveUserDatas int32 = 0 40 41 func TestGlua(t *testing.T) { 42 testScriptDir(t, gluaTests, "_glua-tests") 43 }