aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/calls.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/testes/calls.lua b/testes/calls.lua
index ee8cce73..cd2696e8 100644
--- a/testes/calls.lua
+++ b/testes/calls.lua
@@ -487,5 +487,30 @@ do
487 end 487 end
488end 488end
489 489
490
491do -- check reuse of strings in dumps
492 local str = "|" .. string.rep("X", 50) .. "|"
493 local foo = load(string.format([[
494 local str <const> = "%s"
495 return {
496 function () return str end,
497 function () return str end,
498 function () return str end
499 }
500 ]], str))
501 -- count occurrences of 'str' inside the dump
502 local dump = string.dump(foo)
503 local _, count = string.gsub(dump, str, {})
504 -- there should be only two occurrences:
505 -- one inside the source, other the string itself.
506 assert(count == 2)
507
508 if T then -- check reuse of strings in undump
509 local funcs = load(dump)()
510 assert(string.format("%p", T.listk(funcs[1])[1]) ==
511 string.format("%p", T.listk(funcs[3])[1]))
512 end
513end
514
490print('OK') 515print('OK')
491return deep 516return deep