diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-28 18:38:20 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-28 18:38:20 -0300 |
commit | b5ab31a475ccf5f96c2ffb34fccc1d6592913794 (patch) | |
tree | ef6d2b1844ca672dc81ab4411e37abbef2b7c48f /testes/closure.lua | |
parent | 140cdcced5e28bde7a89e88fcae428f318565f1d (diff) | |
parent | 314745ed8438d1276c6c928d5f9d4be018dfadb6 (diff) | |
download | lua-b5ab31a475ccf5f96c2ffb34fccc1d6592913794.tar.gz lua-b5ab31a475ccf5f96c2ffb34fccc1d6592913794.tar.bz2 lua-b5ab31a475ccf5f96c2ffb34fccc1d6592913794.zip |
Merge branch 'master' into nextversion
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 27ec5596..de1b54ec 100644 --- a/testes/closure.lua +++ b/testes/closure.lua | |||
@@ -4,7 +4,7 @@ | |||
4 | print "testing closures" | 4 | print "testing closures" |
5 | 5 | ||
6 | local A,B = 0,{g=10} | 6 | local A,B = 0,{g=10} |
7 | function f(x) | 7 | local 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 |
@@ -86,6 +86,7 @@ assert(r == 2 and s == "a") | |||
86 | 86 | ||
87 | 87 | ||
88 | -- testing closures with 'for' control variable x break | 88 | -- testing closures with 'for' control variable x break |
89 | local f | ||
89 | for i=1,3 do | 90 | for i=1,3 do |
90 | f = function () return i end | 91 | f = function () return i end |
91 | break | 92 | break |
@@ -136,7 +137,7 @@ assert(b('get') == 'xuxu') | |||
136 | b('set', 10); assert(b('get') == 14) | 137 | b('set', 10); assert(b('get') == 14) |
137 | 138 | ||
138 | 139 | ||
139 | local w | 140 | local y, w |
140 | -- testing multi-level closure | 141 | -- testing multi-level closure |
141 | function f(x) | 142 | function f(x) |
142 | return function (y) | 143 | return function (y) |
@@ -227,6 +228,7 @@ t() | |||
227 | -- test for debug manipulation of upvalues | 228 | -- test for debug manipulation of upvalues |
228 | local debug = require'debug' | 229 | local debug = require'debug' |
229 | 230 | ||
231 | local foo1, foo2, foo3 | ||
230 | do | 232 | do |
231 | local a , b, c = 3, 5, 7 | 233 | local a , b, c = 3, 5, 7 |
232 | foo1 = function () return a+b end; | 234 | foo1 = function () return a+b end; |