lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


--- Rici Lake <lua@ricilake.net> wrote:
> So you could modify that slightly by setting
>      RunTests = "modulename"
> instead of just to true. However, that means
> hard-coding
> the name of the module into the module-file, which I
> wanted to avoid.
> 
Thanks for the suggestion from both.

I am not quite understand the above though.

I took your approach and do it like this :

local __name__
if type(package.loaded["my_module"]) ~= "userdata"
then
__name__ = "__main__"
module("my_module")
...things I write

then at the end, the pythonic way:

if __name__ == "__main__" then <self test> end

Won't this also hardcode the module name in the module
file, right there in the module() call ?



 
____________________________________________________________________________________
Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html