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).
This commit is contained in:
Roberto Ierusalimschy
2020-07-04 16:40:18 -03:00
parent 0280407fc5
commit bfcf06d91a
5 changed files with 30 additions and 17 deletions

View File

@@ -337,7 +337,7 @@ local function endwarn ()
if not T then
warn("@on") -- back to normal
else
assert(_WARN == nil)
assert(_WARN == false)
warn("@normal")
end
end
@@ -346,7 +346,7 @@ end
local function checkwarn (msg)
if T then
assert(string.find(_WARN, msg))
_WARN = nil -- reset variable to check next warning
_WARN = false -- reset variable to check next warning
end
end