aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testes/main.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/testes/main.lua b/testes/main.lua
index da2a9288..b224b54e 100644
--- a/testes/main.lua
+++ b/testes/main.lua
@@ -43,6 +43,8 @@ local function getoutput ()
43end 43end
44 44
45local function checkprogout (s) 45local function checkprogout (s)
46 -- expected result must end with new line
47 assert(string.sub(s, -1) == "\n")
46 local t = getoutput() 48 local t = getoutput()
47 for line in string.gmatch(s, ".-\n") do 49 for line in string.gmatch(s, ".-\n") do
48 assert(string.find(t, line, 1, true)) 50 assert(string.find(t, line, 1, true))
@@ -292,7 +294,7 @@ debug = require"debug"
292print(debug.getinfo(1).currentline) 294print(debug.getinfo(1).currentline)
293]] 295]]
294RUN('lua %s > %s', prog, out) 296RUN('lua %s > %s', prog, out)
295checkprogout('3') 297checkprogout('3\n')
296 298
297-- close Lua with an open file 299-- close Lua with an open file
298prepfile(string.format([[io.output(%q); io.write('alo')]], out)) 300prepfile(string.format([[io.output(%q); io.write('alo')]], out))
@@ -320,15 +322,16 @@ NoRun("", "lua %s", prog) -- no message
320 322
321-- to-be-closed variables in main chunk 323-- to-be-closed variables in main chunk
322prepfile[[ 324prepfile[[
323 local x <close> = function (err) 325 local x <close> = setmetatable({},
324 assert(err == 120) 326 {__close = function (self, err)
325 print("Ok") 327 assert(err == nil)
326 end 328 print("Ok")
327 local e1 <close> = function () error(120) end 329 end})
330 local e1 <close> = setmetatable({}, {__close = function () print(120) end})
328 os.exit(true, true) 331 os.exit(true, true)
329]] 332]]
330RUN('lua %s > %s', prog, out) 333RUN('lua %s > %s', prog, out)
331checkprogout("Ok") 334checkprogout("120\nOk\n")
332 335
333 336
334-- remove temporary files 337-- remove temporary files