aboutsummaryrefslogtreecommitdiff
path: root/testes/locals.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-12-28 18:34:11 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-12-28 18:34:11 -0300
commit314745ed8438d1276c6c928d5f9d4be018dfadb6 (patch)
tree594b7e873f2c29113d95c75147ab10865cdd772c /testes/locals.lua
parent0825cf237d9d3505155f8b40bcf83ea1b135e8da (diff)
downloadlua-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.lua8
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
37f = nil 37f = nil
38 38
39local f 39local f
40x = 1 40local x = 1
41 41
42a = nil 42a = nil
43load('local a = {}')() 43load('local a = {}')()
@@ -152,7 +152,7 @@ local dummy
152local _ENV = (function (...) return ... end)(_G, dummy) -- { 152local _ENV = (function (...) return ... end)(_G, dummy) -- {
153 153
154do local _ENV = {assert=assert}; assert(true) end 154do local _ENV = {assert=assert}; assert(true) end
155mt = {_G = _G} 155local mt = {_G = _G}
156local foo,x 156local foo,x
157A = false -- "declare" A 157A = false -- "declare" A
158do local _ENV = mt 158do local _ENV = mt
@@ -174,6 +174,8 @@ do local _ENV = {assert=assert, A=10};
174end 174end
175assert(x==20) 175assert(x==20)
176 176
177A = nil
178
177 179
178do -- constants 180do -- 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