From 314745ed8438d1276c6c928d5f9d4be018dfadb6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 28 Dec 2022 18:34:11 -0300 Subject: 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. --- testes/locals.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'testes/locals.lua') 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 f = nil local f -x = 1 +local x = 1 a = nil load('local a = {}')() @@ -152,7 +152,7 @@ local dummy local _ENV = (function (...) return ... end)(_G, dummy) -- { do local _ENV = {assert=assert}; assert(true) end -mt = {_G = _G} +local mt = {_G = _G} local foo,x A = false -- "declare" A do local _ENV = mt @@ -174,6 +174,8 @@ do local _ENV = {assert=assert, A=10}; end assert(x==20) +A = nil + do -- constants local a, b, c = 10, 20, 30 @@ -711,7 +713,7 @@ if rawget(_G, "T") then collectgarbage(); collectgarbage() - m = T.totalmem() + local m = T.totalmem() collectgarbage("stop") -- error in the first buffer allocation -- cgit v1.2.3-55-g6feb