mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-15 00:02:49 +03:00
added lua test cases
git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@128 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
31
www/lua/test_lib.lua
Normal file
31
www/lua/test_lib.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local function getfield (t, f)
|
||||
for w in string.gfind(f, "[%w_]+") do
|
||||
if not t then return nil end
|
||||
t = t[w]
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
function test_lib (libname)
|
||||
local ok, err = pcall (require, libname)
|
||||
if not ok then
|
||||
cgilua.put ("Library <tt><b>"..libname.."</b></tt> not found<br>\n"..
|
||||
err)
|
||||
else
|
||||
cgilua.put ("Library <tt><b>"..libname.."</b></tt><br>\n")
|
||||
local t = getfield (_G, libname)
|
||||
if type(t) ~= "table" then
|
||||
cgilua.put (tostring(t))
|
||||
else
|
||||
for i, v in pairs (t) do
|
||||
cgilua.put (" "..tostring(i).." = "..tostring(v).."<br>\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
cgilua.put ("\n<p>\n")
|
||||
end
|
||||
|
||||
cgilua.htmlheader ()
|
||||
for _, lib in ipairs { "lfs", "socket", "luasql.postgres", "luasql", "lxp", "lxp.lom", "lualdap", "htk", "xmlrpc", "xmlrpc.http" } do
|
||||
test_lib (lib)
|
||||
end
|
Reference in New Issue
Block a user