aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-30 13:48:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-30 13:48:40 -0300
commit35b4efc270db2418bc2cac6671575a45028061c3 (patch)
tree04bab8e697e2cb203e7dd04db7e3054fa0de05a4
parent0d529138042563baf260366e19a7aa2c60a07174 (diff)
downloadlua-35b4efc270db2418bc2cac6671575a45028061c3.tar.gz
lua-35b4efc270db2418bc2cac6671575a45028061c3.tar.bz2
lua-35b4efc270db2418bc2cac6671575a45028061c3.zip
Fixed test in 'main.lua'
The test "to-be-closed variables in main chunk" was broken, as it used the removed feature of functions as to-be-closed values. The error was not detected because its expected result had no lines to be checked (due to missing new lines).
-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