/trunk/Examples/test-suite/lua/lua_no_module_global_runme.lua
Lua | 24 lines | 9 code | 7 blank | 8 comment | 6 complexity | 82a69c9d72dfa5ad7e02024e4151289e MD5 | raw file
1-- require is only available in Lua 5.1 2 3if string.sub(_VERSION,1,7)=='Lua 5.1' then 4 5 -- Initially the package should not be loaded 6 assert(package.loaded["lua_no_module_global"] == nil) 7 8 -- Load the module 9 the_module = require "lua_no_module_global" 10 11 -- require should return the module table 12 assert(the_module.hi_mom ~= nil) 13 assert(the_module.hi_mom() == "hi mom!") 14 15 -- But it should not end up in the global table _G, subject to 16 -- the -nomoduleglobal swig option. 17 assert(_G["lua_no_module_global"] == nil) 18 19 -- According to the Lua 5.1 reference manual, require should also 20 -- store the module table into package.loaded["name"] 21 assert(package.loaded["lua_no_module_global"] == the_module) 22 assert(package.loaded["lua_no_module_global"].hi_mom() == "hi mom!") 23 24end