aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/closure.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/testes/closure.lua b/testes/closure.lua
index 5d090d91..cdeaebaa 100644
--- a/testes/closure.lua
+++ b/testes/closure.lua
@@ -44,18 +44,17 @@ assert(B.g == 19)
44 44
45-- testing equality 45-- testing equality
46a = {} 46a = {}
47collectgarbage"stop"
48for i = 1, 5 do a[i] = function (x) return x + a + _ENV end end
49collectgarbage"restart"
50assert(a[3] == a[4] and a[4] == a[5])
51 47
52for i = 1, 5 do a[i] = function (x) return i + a + _ENV end end 48for i = 1, 5 do a[i] = function (x) return i + a + _ENV end end
53assert(a[3] ~= a[4] and a[4] ~= a[5]) 49assert(a[3] ~= a[4] and a[4] ~= a[5])
54 50
55local function f() 51do
56 return function (x) return math.sin(_ENV[x]) end 52 local a = function (x) return math.sin(_ENV[x]) end
53 local function f()
54 return a
55 end
56 assert(f() == f())
57end 57end
58assert(f() == f())
59 58
60 59
61-- testing closures with 'for' control variable 60-- testing closures with 'for' control variable