Option '-l' can give a name for the global variable.

Sintax for this option now is '-l [globname=]modname'.
This commit is contained in:
Roberto Ierusalimschy
2021-08-16 13:57:19 -03:00
parent 59acd79c05
commit 65434b4d1b
2 changed files with 27 additions and 15 deletions

View File

@@ -190,6 +190,11 @@ prepfile(("print(a); print(_G['%s'].x)"):format(prog), otherprog)
RUN('env LUA_PATH="?;;" lua -l %s -l%s -lstring -l io %s > %s', prog, otherprog, otherprog, out)
checkout("1\n2\n15\n2\n15\n")
-- test explicit global names in -l
prepfile("print(str.upper'alo alo', m.max(10, 20))")
RUN("lua -l 'str=string' '-lm=math' -e 'print(m.sin(0))' %s > %s", prog, out)
checkout("0.0\nALO ALO\t20\n")
-- test 'arg' table
local a = [[
assert(#arg == 3 and arg[1] == 'a' and