aboutsummaryrefslogtreecommitdiff
path: root/testes/goto.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/goto.lua')
-rw-r--r--testes/goto.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/testes/goto.lua b/testes/goto.lua
index 3310314d..a692a623 100644
--- a/testes/goto.lua
+++ b/testes/goto.lua
@@ -432,5 +432,27 @@ do print "testing initialization in global declarations"
432 _ENV.a, _ENV.b, _ENV.c, _ENV.d = nil -- erase these globals 432 _ENV.a, _ENV.b, _ENV.c, _ENV.d = nil -- erase these globals
433end 433end
434 434
435do
436 global table, string
437 -- global initialization when names don't fit in K
438
439 -- to fill constant table
440 local code = {}
441 for i = 1, 300 do code[i] = "'" .. i .. "'" end
442 code = table.concat(code, ",")
443 code = string.format([[
444 return function (_ENV)
445 local dummy = {%s} -- fill initial positions in constant table,
446 -- so that initialization must use registers for global names
447 global a, b, c = 10, 20, 30
448 end]], code)
449
450 local fun = assert(load(code))()
451
452 local env = {}
453 fun(env)
454 assert(env.a == 10 and env.b == 20 and env.c == 30)
455end
456
435print'OK' 457print'OK'
436 458