aboutsummaryrefslogtreecommitdiff
path: root/testes/gc.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-23 11:36:09 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-23 11:36:09 -0300
commit9b014d4bcd4ebadb523f1c1a1d38148d8526e5ed (patch)
tree50d7ec68ff36d2fa017b970b11985c6cce5861aa /testes/gc.lua
parent50fd8d03c33bbe52ac5b34c4eb748197b349cedd (diff)
downloadlua-9b014d4bcd4ebadb523f1c1a1d38148d8526e5ed.tar.gz
lua-9b014d4bcd4ebadb523f1c1a1d38148d8526e5ed.tar.bz2
lua-9b014d4bcd4ebadb523f1c1a1d38148d8526e5ed.zip
Details (typos in comments)
Diffstat (limited to 'testes/gc.lua')
-rw-r--r--testes/gc.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index 0693837c..ca8aa1bc 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -446,8 +446,8 @@ do -- tests for string keys in weak tables
446 local m = collectgarbage("count") -- current memory 446 local m = collectgarbage("count") -- current memory
447 local a = setmetatable({}, {__mode = "kv"}) 447 local a = setmetatable({}, {__mode = "kv"})
448 a[string.rep("a", 2^22)] = 25 -- long string key -> number value 448 a[string.rep("a", 2^22)] = 25 -- long string key -> number value
449 a[string.rep("b", 2^22)] = {} -- long string key -> colectable value 449 a[string.rep("b", 2^22)] = {} -- long string key -> collectable value
450 a[{}] = 14 -- colectable key 450 a[{}] = 14 -- collectable key
451 collectgarbage() 451 collectgarbage()
452 local k, v = next(a) -- string key with number value preserved 452 local k, v = next(a) -- string key with number value preserved
453 assert(k == string.rep("a", 2^22) and v == 25) 453 assert(k == string.rep("a", 2^22) and v == 25)
@@ -459,7 +459,7 @@ do -- tests for string keys in weak tables
459 assert(next(a) == nil) 459 assert(next(a) == nil)
460 -- make sure will not try to compare with dead key 460 -- make sure will not try to compare with dead key
461 assert(a[string.rep("b", 100)] == undef) 461 assert(a[string.rep("b", 100)] == undef)
462 assert(collectgarbage("count") <= m + 1) -- eveything collected 462 assert(collectgarbage("count") <= m + 1) -- everything collected
463end 463end
464 464
465 465
@@ -524,7 +524,7 @@ do
524 local co = coroutine.create(f) 524 local co = coroutine.create(f)
525 assert(coroutine.resume(co, co)) 525 assert(coroutine.resume(co, co))
526 end 526 end
527 -- Now, thread and closure are not reacheable any more. 527 -- Now, thread and closure are not reachable any more.
528 collectgarbage() 528 collectgarbage()
529 assert(collected) 529 assert(collected)
530 collectgarbage("restart") 530 collectgarbage("restart")
@@ -644,7 +644,7 @@ do
644 assert(getmetatable(o) == tt) 644 assert(getmetatable(o) == tt)
645 -- create new objects during GC 645 -- create new objects during GC
646 local a = 'xuxu'..(10+3)..'joao', {} 646 local a = 'xuxu'..(10+3)..'joao', {}
647 ___Glob = o -- ressurrect object! 647 ___Glob = o -- resurrect object!
648 setmetatable({}, tt) -- creates a new one with same metatable 648 setmetatable({}, tt) -- creates a new one with same metatable
649 print(">>> closing state " .. "<<<\n") 649 print(">>> closing state " .. "<<<\n")
650 end 650 end