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

@@ -393,12 +393,12 @@ if T then -- test library?
-- testing 'warn'
warn("@store")
warn("@123", "456", "789")
assert(_WARN == "@123456789"); _WARN = nil
assert(_WARN == "@123456789"); _WARN = false
warn("zip", "", " ", "zap")
assert(_WARN == "zip zap"); _WARN = nil
assert(_WARN == "zip zap"); _WARN = false
warn("ZIP", "", " ", "ZAP")
assert(_WARN == "ZIP ZAP"); _WARN = nil
assert(_WARN == "ZIP ZAP"); _WARN = false
warn("@normal")
end