blob: 2bf9d470258f306acb1b27f301ced846eb61baa4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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")
|