change sizeof(a_cast) to sizeof(void*)
[liba.git] / lua / test / test.lua
blob66cbfdf75cd70fee2b95b2d71599af9e2edb72a1
1 local m = {}
2 m.indent = " "
3 function m.dir(...)
4 local io_write_cache = {}
5 local function io_write(indent, x)
6 local str = tostring(x)
7 if io_write_cache[str] then
8 io.write(indent, "*", str, "\n")
9 else
10 io_write_cache[str] = true
11 if type(x) == "table" then
12 for idx, val in pairs(x) do
13 if type(idx) ~= "string" then
14 idx = "[" .. tostring(idx) .. "]"
15 elseif idx:find('"') then
16 idx = '["' .. idx:gsub('"', '\\"') .. '"]'
17 end
18 if type(val) == "table" then
19 io.write(indent, idx, " = ", str, "\n")
20 io.write(indent, "{\n")
21 io_write(indent .. m.indent, val)
22 io.write(indent, "}\n")
23 else
24 if type(val) ~= "string" then
25 val = tostring(val)
26 else
27 val = '"' .. val:gsub('"', '\\"') .. '"'
28 end
29 io.write(indent, idx, " = ", val, ",\n")
30 end
31 end
32 else
33 io.write(indent, str, "\n")
34 end
35 end
36 end
37 for _, x in ipairs({ ... }) do
38 if type(x) == "table" then
39 io.write(tostring(x), "\n")
40 io.write("{\n")
41 io_write(m.indent, x)
42 io.write("}\n")
43 else
44 io_write("", x)
45 end
46 end
47 end
49 function m.log(...)
50 for i, v in ipairs({ ... }) do
51 if i > 1 then
52 io.write(" ")
53 end
54 io.write(tostring(v))
55 end
56 io.write("\n")
57 end
59 function m.fmt(...)
60 io.write(string.format(...), "\n")
61 end
63 return m