aboutsummaryrefslogtreecommitdiff
path: root/testes/closure.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/closure.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/closure.lua')
-rw-r--r--testes/closure.lua6
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 @@
4print "testing closures" 4print "testing closures"
5 5
6local A,B = 0,{g=10} 6local A,B = 0,{g=10}
7function f(x) 7local function f(x)
8 local a = {} 8 local a = {}
9 for i=1,1000 do 9 for i=1,1000 do
10 local y = 0 10 local y = 0
@@ -89,6 +89,7 @@ assert(r == "a" and s == "b")
89 89
90 90
91-- testing closures with 'for' control variable x break 91-- testing closures with 'for' control variable x break
92local f
92for i=1,3 do 93for i=1,3 do
93 f = function () return i end 94 f = function () return i end
94 break 95 break
@@ -139,7 +140,7 @@ assert(b('get') == 'xuxu')
139b('set', 10); assert(b('get') == 14) 140b('set', 10); assert(b('get') == 14)
140 141
141 142
142local w 143local y, w
143-- testing multi-level closure 144-- testing multi-level closure
144function f(x) 145function f(x)
145 return function (y) 146 return function (y)
@@ -230,6 +231,7 @@ t()
230-- test for debug manipulation of upvalues 231-- test for debug manipulation of upvalues
231local debug = require'debug' 232local debug = require'debug'
232 233
234local foo1, foo2, foo3
233do 235do
234 local a , b, c = 3, 5, 7 236 local a , b, c = 3, 5, 7
235 foo1 = function () return a+b end; 237 foo1 = function () return a+b end;