lua/vm_test.go

34 lines
620 B
Go

// Package lua ...
//
// Description : lua ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-11-14 18:08
package lua
import (
"fmt"
"testing"
)
func TestNewVm(t *testing.T) {
scriptTable := map[string]string{
"json": `local json = require("dkjson")
local lua_table = {
name = "wx771720",
age = 18,
married = true,
skills = {"typescript", "unity", "lua"}
}
local json_str = json.encode(lua_table)
print(json_str) -- 输出JSON字符串`,
}
if err := InitVM(1024, nil, scriptTable); err != nil {
panic(err.Error())
}
_, err := VMInstance.RunPreCompileScript("json")
fmt.Println(err)
}