aboutsummaryrefslogtreecommitdiff
path: root/testes/locals.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-04 16:40:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-04 16:40:18 -0300
commitbfcf06d91a87b7ffb8c83e290db0cb6176a167f8 (patch)
tree0bcba905a2772e536c845e39e9eeed0c7330312c /testes/locals.lua
parent0280407fc54f9b6225139c5ac27326f98f0cf043 (diff)
downloadlua-bfcf06d91a87b7ffb8c83e290db0cb6176a167f8.tar.gz
lua-bfcf06d91a87b7ffb8c83e290db0cb6176a167f8.tar.bz2
lua-bfcf06d91a87b7ffb8c83e290db0cb6176a167f8.zip
Avoid memory allocation in some functions from 'ltests.c'
To allow their use in memory tests, some functions in 'ltests.c' should never allocate memory. To avoid this allocation, the library registers the strings used for status codes, and keeps the variable '_WARN' always defined (with false instead of nil).
Diffstat (limited to 'testes/locals.lua')
-rw-r--r--testes/locals.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/testes/locals.lua b/testes/locals.lua
index 0e5e0c74..f5e96244 100644
--- a/testes/locals.lua
+++ b/testes/locals.lua
@@ -337,7 +337,7 @@ local function endwarn ()
337 if not T then 337 if not T then
338 warn("@on") -- back to normal 338 warn("@on") -- back to normal
339 else 339 else
340 assert(_WARN == nil) 340 assert(_WARN == false)
341 warn("@normal") 341 warn("@normal")
342 end 342 end
343end 343end
@@ -346,7 +346,7 @@ end
346local function checkwarn (msg) 346local function checkwarn (msg)
347 if T then 347 if T then
348 assert(string.find(_WARN, msg)) 348 assert(string.find(_WARN, msg))
349 _WARN = nil -- reset variable to check next warning 349 _WARN = false -- reset variable to check next warning
350 end 350 end
351end 351end
352 352