Lua 5.2 compatibility fixes.
This commit is contained in:
@@ -122,7 +122,7 @@ local fields = { 'source', 'short_src', 'what',
|
||||
'currentline', 'linedefined', 'lastlinedefined',
|
||||
'nups', 'func', 'activelines' }
|
||||
local printinfo = function(...)
|
||||
for i,a in ipairs(arg) do
|
||||
for i,a in ipairs({...}) do
|
||||
if type(a) == 'table' then
|
||||
for j,field in ipairs(fields) do
|
||||
printfield( a, field)
|
||||
|
||||
@@ -29,11 +29,6 @@ checkallpass('table.insert',{sometable,somei,notanil})
|
||||
checkallerrors('table.insert',{notatable,somestring},'bad argument')
|
||||
checkallerrors('table.insert',{sometable,notij,notanil},'bad argument')
|
||||
|
||||
-- table.maxn
|
||||
banner('table.maxn')
|
||||
checkallpass('table.maxn',{sometable})
|
||||
checkallerrors('table.maxn',{notatable},'bad argument')
|
||||
|
||||
-- table.remove
|
||||
banner('table.remove')
|
||||
checkallpass('table.remove',{sometable})
|
||||
|
||||
@@ -52,7 +52,7 @@ function eles(t,f)
|
||||
return "{"..table.concat(all,',').."}"
|
||||
end
|
||||
|
||||
-- insert, maxn
|
||||
-- insert, len
|
||||
print( '-- insert, len tests' )
|
||||
local t = { "one", "two", "three", a='aaa', b='bbb', c='ccc' }
|
||||
|
||||
@@ -105,40 +105,6 @@ sorttest{ "one", "two", "three" }
|
||||
sorttest{ "www", "vvv", "uuu", "ttt", "sss", "zzz", "yyy", "xxx" }
|
||||
sorttest( { "www", "vvv", "uuu", "ttt", "sss", "zzz", "yyy", "xxx" }, function(a,b) return b<a end)
|
||||
|
||||
-- getn
|
||||
t0 = {}
|
||||
t1 = { 'one', 'two', 'three' }
|
||||
t2 = { a1='aa', a2='bb', a3='cc' }
|
||||
t3 = { 'one', 'two', 'three', a1='aa', a2='bb', a3='cc' }
|
||||
print( 'getn('..eles(t0)..')', pcall( table.getn, t0 ) )
|
||||
print( 'getn('..eles(t1)..')', pcall( table.getn, t1 ) )
|
||||
print( 'getn('..eles(t2)..')', pcall( table.getn, t2 ) )
|
||||
print( 'getn('..eles(t3)..')', pcall( table.getn, t3 ) )
|
||||
|
||||
-- foreach
|
||||
function test( f, t, result, name )
|
||||
status, value = pcall( f, t, function(...)
|
||||
print(' -- ',...)
|
||||
print(' next',next(t,(...)))
|
||||
return result
|
||||
end )
|
||||
print( name, 's,v', status, value )
|
||||
end
|
||||
function testall( f, t, name )
|
||||
test( f, t, nil, name..'nil' )
|
||||
test( f, t, false, name..'fls' )
|
||||
test( f, t, 100, name..'100' )
|
||||
end
|
||||
testall( table.foreach, t0, 'table.foreach('..eles(t0)..')' )
|
||||
testall( table.foreach, t1, 'table.foreach('..eles(t1)..')' )
|
||||
testall( table.foreach, t2, 'table.foreach('..eles(t2)..')' )
|
||||
testall( table.foreach, t3, 'table.foreach('..eles(t3)..')' )
|
||||
testall( table.foreachi, t0, 'table.foreachi('..eles(t0)..')' )
|
||||
testall( table.foreachi, t1, 'table.foreachi('..eles(t1)..')' )
|
||||
testall( table.foreachi, t2, 'table.foreachi('..eles(t2)..')' )
|
||||
testall( table.foreachi, t3, 'table.foreachi('..eles(t3)..')' )
|
||||
|
||||
|
||||
-- pairs, ipairs
|
||||
--[[
|
||||
function testpairs(f, t, name)
|
||||
|
||||
@@ -50,7 +50,7 @@ local function varargstest()
|
||||
print("a,arg[1],arg[2],arg[3]",a,arg.n,arg[1],arg[2],arg[3])
|
||||
end
|
||||
function r(a,...)
|
||||
print("a,arg",a,arg)
|
||||
print("a,arg[1],arg[2],arg[3]",a,arg.n,arg[1],arg[2],arg[3])
|
||||
print("a",a)
|
||||
print("...",...)
|
||||
print("...,a",...,a)
|
||||
|
||||
Reference in New Issue
Block a user