fix endless recursion when using inspect to reimplement global tostring

This commit is contained in:
Andreas Hofer
2016-03-29 22:53:26 +02:00
parent a998635207
commit d051ae061c
2 changed files with 22 additions and 5 deletions

View File

@@ -411,4 +411,19 @@ describe( 'inspect', function()
end)
end)
end)
it('allows changing the global tostring', function()
local save = _G.tostring
_G.tostring = function(x)
if type(x) == "string" then
return x
else
return inspect(x)
end
end
local s = tostring({1, 2, 3})
_G.tostring = save
assert.equals("{ 1, 2, 3 }", s)
end)
end)