mike: Added testing file slated to replace tserial
This commit is contained in:
parent
af9aef995e
commit
48611008dc
51
love/mike/lib/testing.lua
Normal file
51
love/mike/lib/testing.lua
Normal file
@ -0,0 +1,51 @@
|
||||
require "io"
|
||||
|
||||
t = {}
|
||||
t.jerk = "dick"
|
||||
t.saint = "Brit"
|
||||
t.num = 92
|
||||
t.multi = {}
|
||||
t.multi.cat = "mu mu"
|
||||
t.multi.dog = "iz"
|
||||
t.multi.number = 53
|
||||
|
||||
function printf (s, ...)
|
||||
return io.write(s:format(...))
|
||||
end
|
||||
|
||||
function print_table(tbl, only_once)
|
||||
if only_once == nil then
|
||||
printf("{")
|
||||
end
|
||||
for key,value in pairs(tbl) do
|
||||
if type(value) == "table" then
|
||||
printf("%s = {\n",key)
|
||||
print_table(value, true)
|
||||
printf("}\n")
|
||||
end
|
||||
if type (value) ~= "table" then
|
||||
if type(value) == "string" then
|
||||
printf("%s = \"%s\"\n", key, value)
|
||||
else
|
||||
printf("%s = %d\n", key, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
if only_once == nil then
|
||||
printf("}\n")
|
||||
end
|
||||
end
|
||||
|
||||
function tablelength(tbl, count)
|
||||
local count = count or 0
|
||||
|
||||
for key, value in pairs(tbl) do
|
||||
if type(value) == "table" then
|
||||
count = tablelength(value, count)
|
||||
end
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
print_table(t)
|
Loading…
x
Reference in New Issue
Block a user