mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +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:
46
www/lua/test_main.lua
Normal file
46
www/lua/test_main.lua
Normal file
@ -0,0 +1,46 @@
|
||||
cgilua.htmlheader()
|
||||
cgilua.put[[
|
||||
<html>
|
||||
<head><title>Script Lua Test</title></head>
|
||||
|
||||
<body>
|
||||
cgi = {
|
||||
]]
|
||||
|
||||
for i,v in pairs (cgi) do
|
||||
if type(v) == "table" then
|
||||
local vv = "{"
|
||||
for a,b in pairs(v) do
|
||||
vv = string.format ("%s%s = %s<br>\n", vv, a, tostring(b))
|
||||
end
|
||||
v = vv.."}"
|
||||
end
|
||||
cgilua.put (string.format ("%s = %s<br>\n", i, tostring(v)))
|
||||
end
|
||||
cgilua.put "}<br>\n"
|
||||
cgilua.put ("Remote address: "..cgilua.servervariable"REMOTE_ADDR")
|
||||
cgilua.put "<br>\n"
|
||||
cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."<br>\n")
|
||||
cgilua.put ("ap="..tostring(ap).."<br>\n")
|
||||
cgilua.put ("lfcgi="..tostring(lfcgi).."<br>\n")
|
||||
|
||||
-- Checking Virtual Environment
|
||||
local my_output = cgilua.put
|
||||
cgilua.put = nil
|
||||
local status, err = pcall (function ()
|
||||
assert (cgilua.put == nil, "cannot change cgilua.put value")
|
||||
end)
|
||||
cgilua.put = my_output
|
||||
assert (status == true, err)
|
||||
|
||||
-- Checking require
|
||||
local status, err = pcall (function () require"unknown_module" end)
|
||||
assert (status == false, "<tt>unknown_module</tt> loaded!")
|
||||
-- assert (package == nil, "Access to <tt>package</tt> table allowed!")
|
||||
|
||||
cgilua.put[[
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
||||
]]
|
||||
cgilua = nil
|
Reference in New Issue
Block a user