2
0

test_lib.lua 796 B

12345678910111213141516171819202122232425262728293031
  1. local function getfield (t, f)
  2. for w in string.gfind(f, "[%w_]+") do
  3. if not t then return nil end
  4. t = t[w]
  5. end
  6. return t
  7. end
  8. function test_lib (libname)
  9. local ok, err = pcall (require, libname)
  10. if not ok then
  11. cgilua.put ("Library <tt><b>"..libname.."</b></tt> not found<br>\n"..
  12. err)
  13. else
  14. cgilua.put ("Library <tt><b>"..libname.."</b></tt><br>\n")
  15. local t = getfield (_G, libname)
  16. if type(t) ~= "table" then
  17. cgilua.put (tostring(t))
  18. else
  19. for i, v in pairs (t) do
  20. cgilua.put ("&nbsp;&nbsp;"..tostring(i).." = "..tostring(v).."<br>\n")
  21. end
  22. end
  23. end
  24. cgilua.put ("\n<p>\n")
  25. end
  26. cgilua.htmlheader ()
  27. for _, lib in ipairs { "lfs", "socket", "luasql.postgres", "luasql", "lxp", "lxp.lom", "lualdap", "htk", "xmlrpc", "xmlrpc.http" } do
  28. test_lib (lib)
  29. end