1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
require "lunit"
module("test.pristine", lunit.testcase, package.seeall)
function test_no_global_clobbering ()
local globals = {}
for key in pairs(_G) do globals[key] = true end
-- Load all the modules for the different types of URIs, in case any one
-- of those treads on a global. I keep them around in a table to make
-- sure they're all loaded at the same time, just in case that does
-- anything interesting.
local schemes = {
"_login", "_relative", "_util", "data",
"file", "file.unix", "file.win32",
"ftp", "http", "https",
"pop", "rtsp", "rtspu", "telnet",
"urn", "urn.isbn", "urn.issn", "urn.oid"
}
local loaded = {}
local URI = require "uri"
for _, name in ipairs(schemes) do
loaded[name] = require("uri." .. name)
end
for key in pairs(_G) do
lunit.assert_not_nil(globals[key],
"global '" .. key .. "' created by lib")
end
for key in pairs(globals) do
lunit.assert_not_nil(_G[key],
"global '" .. key .. "' destroyed by lib")
end
end
-- vi:ts=4 sw=4 expandtab
|