aboutsummaryrefslogtreecommitdiff
path: root/testes/locals.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/locals.lua')
-rw-r--r--testes/locals.lua24
1 files changed, 6 insertions, 18 deletions
diff --git a/testes/locals.lua b/testes/locals.lua
index dccda28f..a41b6f0e 100644
--- a/testes/locals.lua
+++ b/testes/locals.lua
@@ -517,27 +517,15 @@ do
517 end 517 end
518 assert(s == 35 and numopen == 0) 518 assert(s == 35 and numopen == 0)
519 519
520 -- repeat test with '__open' metamethod instead of a function
521 local function open (x)
522 numopen = numopen + 1
523 local state = setmetatable({x},
524 {__close = function () numopen = numopen - 1 end})
525 return
526 function (t) -- iteraction function
527 t[1] = t[1] - 1
528 if t[1] > 0 then return t[1] end
529 end,
530 state,
531 nil,
532 state -- to-be-closed
533 end
534
535 local s = 0 520 local s = 0
536 for i in open(10) do 521 for i in open(10) do
537 if (i < 5) then break end 522 for j in open(10) do
538 s = s + i 523 if i + j < 5 then goto endloop end
524 s = s + i
525 end
539 end 526 end
540 assert(s == 35 and numopen == 0) 527 ::endloop::
528 assert(s == 375 and numopen == 0)
541end 529end
542 530
543print('OK') 531print('OK')