diff options
Diffstat (limited to 'test/lua')
-rwxr-xr-x | test/lua/script_args.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/lua/script_args.lua b/test/lua/script_args.lua new file mode 100755 index 0000000000..2bf9d47025 --- /dev/null +++ b/test/lua/script_args.lua @@ -0,0 +1,36 @@ +---------------------------------------- +-- This just verifies the number of args it got is what it expected. +-- The first arg should be a number, for how many total args to expect, +-- including itself. + +local function testing(...) + print("---- Testing "..tostring(...).." ----") +end + +local function test(name, result) + io.stdout:write("test "..name.."...") + if result == true then + io.stdout:write("passed\n") + else + io.stdout:write("failed!\n") + error(name.." test failed!") + end +end + +----------------------------- + +testing("Command-line args") + +local arg={...} -- get passed-in args + +test("arg1", arg ~= nil and #arg > 0) + +local numargs = tonumber(arg[1]) +test("arg2", numargs ~= nil) + +test("arg3", #arg == numargs) + +print("\n-----------------------------\n") + +print("All tests passed!\n\n") + |