diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-30 13:48:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-30 13:48:40 -0300 |
commit | 35b4efc270db2418bc2cac6671575a45028061c3 (patch) | |
tree | 04bab8e697e2cb203e7dd04db7e3054fa0de05a4 | |
parent | 0d529138042563baf260366e19a7aa2c60a07174 (diff) | |
download | lua-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.lua | 17 |
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 () | |||
43 | end | 43 | end |
44 | 44 | ||
45 | local function checkprogout (s) | 45 | local 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" | |||
292 | print(debug.getinfo(1).currentline) | 294 | print(debug.getinfo(1).currentline) |
293 | ]] | 295 | ]] |
294 | RUN('lua %s > %s', prog, out) | 296 | RUN('lua %s > %s', prog, out) |
295 | checkprogout('3') | 297 | checkprogout('3\n') |
296 | 298 | ||
297 | -- close Lua with an open file | 299 | -- close Lua with an open file |
298 | prepfile(string.format([[io.output(%q); io.write('alo')]], out)) | 300 | prepfile(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 |
322 | prepfile[[ | 324 | prepfile[[ |
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 | ]] |
330 | RUN('lua %s > %s', prog, out) | 333 | RUN('lua %s > %s', prog, out) |
331 | checkprogout("Ok") | 334 | checkprogout("120\nOk\n") |
332 | 335 | ||
333 | 336 | ||
334 | -- remove temporary files | 337 | -- remove temporary files |