From 1c096cdd3cd2063f766eb0721b4c17c9f0f63883 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 17 Aug 2024 17:25:32 +0200 Subject: [PATCH] add lua sample and definition file in lua --- meta/uname.lua | 25 +++++++++++++++++++++++++ test_uname.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 meta/uname.lua create mode 100644 test_uname.lua diff --git a/meta/uname.lua b/meta/uname.lua new file mode 100644 index 0000000..0522928 --- /dev/null +++ b/meta/uname.lua @@ -0,0 +1,25 @@ +---@meta uname + +---@class unamelib +local uname = {} + +---@param x integer +---@return integer +---@nodiscard +function uname.numid(x) end + +---@param x integer +---@return integer +---@nodiscard +function uname.plusone(x) end + +---@class uname +---@field sysname string +---@field machine string +---@field release string +---@field version string + +---@return uname +function uname.uname() end + +return uname diff --git a/test_uname.lua b/test_uname.lua new file mode 100644 index 0000000..dec3b36 --- /dev/null +++ b/test_uname.lua @@ -0,0 +1,27 @@ +---@module 'uname' +local uname +uname = require'uname' + +print(uname) + +for k, v in pairs(uname) do + print(k, v) +end + +print("numid", uname.numid(1)) +do + local result, ret = xpcall(uname.numid, debug.traceback, "a", "b") + if not result then + io.stderr:write("error" .. ret .. "\n") + else + print("result: " .. ret) + end +end + +print(type(uname.uname())) +print("uname") +for k, v in pairs(uname.uname()) do + print(k, v) +end +print("OS is " .. uname.uname().sysname) +