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/locals.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/locals.lua')
-rw-r--r-- | testes/locals.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index d50beaa5..2c48546d 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
@@ -37,7 +37,7 @@ end | |||
37 | f = nil | 37 | f = nil |
38 | 38 | ||
39 | local f | 39 | local f |
40 | x = 1 | 40 | local x = 1 |
41 | 41 | ||
42 | a = nil | 42 | a = nil |
43 | load('local a = {}')() | 43 | load('local a = {}')() |
@@ -152,7 +152,7 @@ local dummy | |||
152 | local _ENV = (function (...) return ... end)(_G, dummy) -- { | 152 | local _ENV = (function (...) return ... end)(_G, dummy) -- { |
153 | 153 | ||
154 | do local _ENV = {assert=assert}; assert(true) end | 154 | do local _ENV = {assert=assert}; assert(true) end |
155 | mt = {_G = _G} | 155 | local mt = {_G = _G} |
156 | local foo,x | 156 | local foo,x |
157 | A = false -- "declare" A | 157 | A = false -- "declare" A |
158 | do local _ENV = mt | 158 | do local _ENV = mt |
@@ -174,6 +174,8 @@ do local _ENV = {assert=assert, A=10}; | |||
174 | end | 174 | end |
175 | assert(x==20) | 175 | assert(x==20) |
176 | 176 | ||
177 | A = nil | ||
178 | |||
177 | 179 | ||
178 | do -- constants | 180 | do -- constants |
179 | local a<const>, b, c<const> = 10, 20, 30 | 181 | local a<const>, b, c<const> = 10, 20, 30 |
@@ -711,7 +713,7 @@ if rawget(_G, "T") then | |||
711 | 713 | ||
712 | collectgarbage(); collectgarbage() | 714 | collectgarbage(); collectgarbage() |
713 | 715 | ||
714 | m = T.totalmem() | 716 | local m = T.totalmem() |
715 | collectgarbage("stop") | 717 | collectgarbage("stop") |
716 | 718 | ||
717 | -- error in the first buffer allocation | 719 | -- error in the first buffer allocation |