mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
'print' does not call 'tostring' to format its arguments
This commit is contained in:
parent
979ad95eb1
commit
8ba4523ccc
3 changed files with 16 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue