'print' does not call 'tostring' to format its arguments

This commit is contained in:
Roberto Ierusalimschy
2019-04-10 12:58:14 -03:00
parent 979ad95eb1
commit 8ba4523ccc
3 changed files with 16 additions and 28 deletions

View File

@@ -21,21 +21,6 @@ assert(type(f) == 'function')
assert(not pcall(type))
do -- test error in 'print' too...
local tostring = _ENV.tostring
_ENV.tostring = nil
local st, msg = pcall(print, 1)
assert(st == false and string.find(msg, "attempt to call a nil value"))
_ENV.tostring = function () return {} end
local st, msg = pcall(print, 1)
assert(st == false and string.find(msg, "must return a string"))
_ENV.tostring = tostring
end
-- testing local-function recursion
fact = false
do