push(c) 396e1e1cf5af4c5433b28ed0af7a7fa4394c1005
[tagua/yd.git] / tests / test.lua
blobf6c03d64a5e22294aa8c6747af1c4a0608750f4f
1 function out(x)
2 dump(x, "", "")
3 end
5 function dump(x, indent1, indent2)
6 mt = getmetatable(x)
7 if mt then
8 io.write("> metatable: ")
9 dump(mt, "", indent2 .. " ")
10 io.write("> object: ")
11 else
12 io.write(indent1)
13 end
14 if type(x) == "string" then
15 io.write(x)
16 elseif type(x) == "number" then
17 io.write(x)
18 elseif type(x) == "table" then
19 print("{")
20 for k, v in pairs(x) do
21 dump(k, indent2 .. " ", indent2 .. " ")
22 io.write(" = ")
23 dump(v, "", indent2 .. " ")
24 print("")
25 end
26 print(indent2 .. "}")
27 else
28 io.write("<" .. type(x) .. ">")
29 end
30 end
32 function debug()
33 print "Rect"
34 out(Rect)
35 print ""
37 print "r"
38 out(r)
39 print ""
40 end
42 r = Rect(2, 3, 100, 400)
43 print(r:height())