diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-28 18:34:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-28 18:34:11 -0300 |
commit | 314745ed8438d1276c6c928d5f9d4be018dfadb6 (patch) | |
tree | 594b7e873f2c29113d95c75147ab10865cdd772c /testes/files.lua | |
parent | 0825cf237d9d3505155f8b40bcf83ea1b135e8da (diff) | |
download | lua-314745ed8438d1276c6c928d5f9d4be018dfadb6.tar.gz lua-314745ed8438d1276c6c928d5f9d4be018dfadb6.tar.bz2 lua-314745ed8438d1276c6c928d5f9d4be018dfadb6.zip |
Avoid excessive name pollution in test files
Test files are more polite regarding the use of globals when locals
would do, and when globals are necessary deleting them after use.
Diffstat (limited to 'testes/files.lua')
-rw-r--r-- | testes/files.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/testes/files.lua b/testes/files.lua index 78f962e5..be00bf3f 100644 --- a/testes/files.lua +++ b/testes/files.lua | |||
@@ -507,15 +507,17 @@ load((io.lines(file, 1)))() | |||
507 | assert(_G.X == 4) | 507 | assert(_G.X == 4) |
508 | load((io.lines(file, 3)))() | 508 | load((io.lines(file, 3)))() |
509 | assert(_G.X == 8) | 509 | assert(_G.X == 8) |
510 | _G.X = nil | ||
510 | 511 | ||
511 | print('+') | 512 | print('+') |
512 | 513 | ||
513 | local x1 = "string\n\n\\com \"\"''coisas [[estranhas]] ]]'" | 514 | local x1 = "string\n\n\\com \"\"''coisas [[estranhas]] ]]'" |
514 | io.output(file) | 515 | io.output(file) |
515 | assert(io.write(string.format("x2 = %q\n-- comment without ending EOS", x1))) | 516 | assert(io.write(string.format("X2 = %q\n-- comment without ending EOS", x1))) |
516 | io.close() | 517 | io.close() |
517 | assert(loadfile(file))() | 518 | assert(loadfile(file))() |
518 | assert(x1 == x2) | 519 | assert(x1 == _G.X2) |
520 | _G.X2 = nil | ||
519 | print('+') | 521 | print('+') |
520 | assert(os.remove(file)) | 522 | assert(os.remove(file)) |
521 | assert(not os.remove(file)) | 523 | assert(not os.remove(file)) |