Add test for combination of print() and tostring(), test case when tostring is changed in global environment.

This commit is contained in:
James Roseborough
2008-07-23 21:08:09 +00:00
parent 989164405d
commit 5da65f7d41
4 changed files with 42 additions and 2 deletions

26
src/test/res/print.lua Normal file
View File

@@ -0,0 +1,26 @@
-- print uses tostring under-the-hood!
local function f()
print()
print('abc')
print(123)
print(true)
print('abc',123,true)
end
local function g()
local fenv = {tostring=function(x)
return '*'..type(x)..'*'
end}
package.seeall(fenv)
f()
print('setfenv', pcall(setfenv, 0, fenv), {}, f )
f()
end
local s,c = pcall( coroutine.create, g )
print('create', s, s and type(c) or c)
print('resume', pcall( coroutine.resume, c ) )
f()