diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-04-03 12:56:52 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-04-03 12:56:52 -0300 |
commit | 620f49a7aae8a5c982b21f0accbf2ff9019a55f6 (patch) | |
tree | 4ba9f6063434759963cc5207b4703248687be793 /testes | |
parent | 3f4f28010aa5065456f1edf97de1ab268cc49944 (diff) | |
download | lua-620f49a7aae8a5c982b21f0accbf2ff9019a55f6.tar.gz lua-620f49a7aae8a5c982b21f0accbf2ff9019a55f6.tar.bz2 lua-620f49a7aae8a5c982b21f0accbf2ff9019a55f6.zip |
Tiny refactoring in io.flush
Diffstat (limited to 'testes')
-rw-r--r-- | testes/files.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/testes/files.lua b/testes/files.lua index 2c802047..53edf314 100644 --- a/testes/files.lua +++ b/testes/files.lua | |||
@@ -347,7 +347,7 @@ collectgarbage() | |||
347 | 347 | ||
348 | assert(io.write(' ' .. t .. ' ')) | 348 | assert(io.write(' ' .. t .. ' ')) |
349 | assert(io.write(';', 'end of file\n')) | 349 | assert(io.write(';', 'end of file\n')) |
350 | f:flush(); io.flush() | 350 | assert(f:flush()); assert(io.flush()) |
351 | f:close() | 351 | f:close() |
352 | print('+') | 352 | print('+') |
353 | 353 | ||
@@ -461,6 +461,23 @@ do -- testing closing file in line iteration | |||
461 | end | 461 | end |
462 | 462 | ||
463 | 463 | ||
464 | do print("testing flush") | ||
465 | local f = io.output("/dev/null") | ||
466 | assert(f:write("abcd")) -- write to buffer | ||
467 | assert(f:flush()) -- write to device | ||
468 | assert(f:write("abcd")) -- write to buffer | ||
469 | assert(io.flush()) -- write to device | ||
470 | assert(f:close()) | ||
471 | |||
472 | local f = io.output("/dev/full") | ||
473 | assert(f:write("abcd")) -- write to buffer | ||
474 | assert(not f:flush()) -- cannot write to device | ||
475 | assert(f:write("abcd")) -- write to buffer | ||
476 | assert(not io.flush()) -- cannot write to device | ||
477 | assert(f:close()) | ||
478 | end | ||
479 | |||
480 | |||
464 | -- test for multipe arguments in 'lines' | 481 | -- test for multipe arguments in 'lines' |
465 | io.output(file); io.write"0123456789\n":close() | 482 | io.output(file); io.write"0123456789\n":close() |
466 | for a,b in io.lines(file, 1, 1) do | 483 | for a,b in io.lines(file, 1, 1) do |