update test
This commit is contained in:
parent
3253191437
commit
6df50488ba
24
vm_test.go
24
vm_test.go
@ -23,6 +23,27 @@ skills = {"typescript", "unity", "lua"}
|
|||||||
}
|
}
|
||||||
local json_str = json.encode(lua_table)
|
local json_str = json.encode(lua_table)
|
||||||
print(json_str) -- 输出JSON字符串`,
|
print(json_str) -- 输出JSON字符串`,
|
||||||
|
|
||||||
|
"http": `
|
||||||
|
local http = require("http.request")
|
||||||
|
|
||||||
|
-- 创建一个HTTP请求的选项表
|
||||||
|
local options = {
|
||||||
|
url = "http://example.com",
|
||||||
|
method = "GET",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- 发起请求
|
||||||
|
local res, code = http.request(options)
|
||||||
|
|
||||||
|
-- 检查请求是否成功
|
||||||
|
if code == 200 then
|
||||||
|
print("请求成功,下面是返回内容:")
|
||||||
|
print(res)
|
||||||
|
else
|
||||||
|
print("请求失败,状态码:" .. code)
|
||||||
|
end
|
||||||
|
`,
|
||||||
}
|
}
|
||||||
if err := InitVM(1024, nil, scriptTable); err != nil {
|
if err := InitVM(1024, nil, scriptTable); err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
@ -30,4 +51,7 @@ print(json_str) -- 输出JSON字符串`,
|
|||||||
|
|
||||||
_, err := VMInstance.RunPreCompileScript("json")
|
_, err := VMInstance.RunPreCompileScript("json")
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|
||||||
|
_, err = VMInstance.RunPreCompileScript("http")
|
||||||
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user