Improve error reporting.
This commit is contained in:
@@ -19,17 +19,17 @@ checkallerrors('collectgarbage',{{aboolean, atable, afunction, athread}},'string
|
||||
banner('dofile')
|
||||
checkallpass('dofile', {})
|
||||
checkallpass('dofile', {{'test/lua/errors/args.lua'}})
|
||||
checkallerrors('dofile', {{'args.lua'}}, 'cannot open args.lua')
|
||||
checkallerrors('dofile', {{'foo.bar'}}, 'cannot open foo.bar')
|
||||
checkallerrors('dofile', {nonstring}, 'bad argument')
|
||||
|
||||
-- error
|
||||
banner('error')
|
||||
checkallerrors('error', {{'message'},{nil,0,1,2}}, 'message')
|
||||
checkallerrors('error', {{123},{nil,1,2}}, 123)
|
||||
checkallerrors('error', {{'message'},{nil,0,1,2,n=4}}, 'message')
|
||||
checkallerrors('error', {{123},{nil,1,2,n=3}}, 123)
|
||||
|
||||
-- getfenv
|
||||
banner('getfenv')
|
||||
checkallpass('getfenv', {{nil,print,function()end,0,1,2}})
|
||||
checkallpass('getfenv', {{nil,print,function()end,0,1,2,n=5}})
|
||||
checkallerrors('getfenv', {{true,{},'abc'}}, 'bad argument')
|
||||
|
||||
-- getmetatable
|
||||
@@ -44,8 +44,8 @@ checkallerrors('ipairs', {notatable}, 'bad argument')
|
||||
|
||||
-- load
|
||||
banner('load')
|
||||
checkallpass('load', {somefunction,{nil,astring}})
|
||||
checkallerrors('load', {notafunction,{nil,astring,anumber}}, 'bad argument')
|
||||
checkallpass('load', {somefunction,{nil,astring,n=2}})
|
||||
checkallerrors('load', {notafunction,{nil,astring,anumber,n=3}}, 'bad argument')
|
||||
checkallerrors('load', {somefunction,{afunction,atable}}, 'bad argument')
|
||||
|
||||
-- loadfile
|
||||
@@ -62,13 +62,13 @@ checkallpass('loadstring', {{'return'}})
|
||||
checkallpass('loadstring', {{'return'},{'mychunk'}})
|
||||
checkallpass('loadstring', {{'return a ... b'},{'mychunk'}},true)
|
||||
checkallerrors('loadstring', {{'return a ... b'},{'mychunk'}},'hello')
|
||||
checkallerrors('loadstring', {notastring,{nil,astring,anumber}}, 'bad argument')
|
||||
checkallerrors('loadstring', {notastring,{nil,astring,anumber,n=3}}, 'bad argument')
|
||||
checkallerrors('loadstring', {{'return'},{afunction,atable}}, 'bad argument')
|
||||
|
||||
-- next
|
||||
banner('next')
|
||||
checkallpass('next', {sometable,somekey})
|
||||
checkallerrors('next', {notatable,{nil,1}}, 'bad argument')
|
||||
checkallerrors('next', {notatable,{nil,1,n=2}}, 'bad argument')
|
||||
checkallerrors('next', {sometable,nonkey}, 'invalid key')
|
||||
|
||||
-- pairs
|
||||
@@ -84,7 +84,7 @@ checkallerrors('pcall',{},'bad argument')
|
||||
-- print
|
||||
banner('print')
|
||||
checkallpass('print', {})
|
||||
checkallpass('print', {{nil,astring,anumber,aboolean}})
|
||||
checkallpass('print', {{nil,astring,anumber,aboolean,n=4}})
|
||||
|
||||
-- rawequal
|
||||
banner('rawequal')
|
||||
@@ -135,9 +135,9 @@ checkallerrors('setmetatable',{sometable,notatable},'bad argument')
|
||||
|
||||
-- tonumber
|
||||
banner('tonumber')
|
||||
checkallpass('tonumber',{somenumber,{nil,2,10,36}})
|
||||
checkallpass('tonumber',{notanil,{nil,10}})
|
||||
checkallerrors('tonumber',{{nil,afunction,atable},{2,9,11,36}},'bad argument')
|
||||
checkallpass('tonumber',{somenumber,{nil,2,10,36,n=4}})
|
||||
checkallpass('tonumber',{notanil,{nil,10,n=2}})
|
||||
checkallerrors('tonumber',{{nil,afunction,atable,n=3},{2,9,11,36}},'bad argument')
|
||||
checkallerrors('tonumber',{somenumber,{1,37,atable,afunction,aboolean}},'bad argument')
|
||||
|
||||
-- tostring
|
||||
|
||||
Reference in New Issue
Block a user