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/closure.lua | |
parent | 0825cf237d9d3505155f8b40bcf83ea1b135e8da (diff) | |
download | lua-github-314745ed8438d1276c6c928d5f9d4be018dfadb6.tar.gz |
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/closure.lua')
-rw-r--r-- | testes/closure.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/testes/closure.lua b/testes/closure.lua index c2453677..ea038e82 100644 --- a/testes/closure.lua +++ b/testes/closure.lua @@ -4,7 +4,7 @@ print "testing closures" local A,B = 0,{g=10} -function f(x) +local function f(x) local a = {} for i=1,1000 do local y = 0 @@ -89,6 +89,7 @@ assert(r == "a" and s == "b") -- testing closures with 'for' control variable x break +local f for i=1,3 do f = function () return i end break @@ -139,7 +140,7 @@ assert(b('get') == 'xuxu') b('set', 10); assert(b('get') == 14) -local w +local y, w -- testing multi-level closure function f(x) return function (y) @@ -230,6 +231,7 @@ t() -- test for debug manipulation of upvalues local debug = require'debug' +local foo1, foo2, foo3 do local a , b, c = 3, 5, 7 foo1 = function () return a+b end; |