[NOTHING CHANGED] Assorted fixes #48

Closed
asiekierka wants to merge 61 commits from asiekierka/master into master
5 changed files with 28 additions and 29 deletions
Showing only changes of commit 58a4dec882 - Show all commits

View File

@@ -24,6 +24,7 @@ somenumber = { anumber, astrnum }
someboolean = { aboolean } someboolean = { aboolean }
sometable = { atable } sometable = { atable }
somefunction = { afunction } somefunction = { afunction }
somethread = { athread }
somenil = { anil } somenil = { anil }
somekey = { akey } somekey = { akey }
notakey = { astring, anumber, aboolean, atable, afunction } notakey = { astring, anumber, aboolean, atable, afunction }

View File

@@ -40,24 +40,17 @@ checkallerrors('ipairs', {notatable}, 'bad argument')
-- load -- load
banner('load') banner('load')
checkallpass('load', {somefunction,{nil,astring,n=2}}) 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
banner('loadfile')
--checkallpass('loadfile', {})
--checkallpass('loadfile', {{'bogus'}})
--checkallpass('loadfile', {{'test/lua/errors/args.lua'}})
--checkallpass('loadfile', {{'args.lua'}})
--checkallerrors('loadfile', {nonstring}, 'bad argument')
-- load
banner('load')
checkallpass('load', {{'return'}}) checkallpass('load', {{'return'}})
checkallpass('load', {{'return'},{'mychunk'}}) checkallpass('load', {{'return'},{'mychunk'}})
checkallpass('load', {{'return a ... b'},{'mychunk'}},true) checkallpass('load', {{'return a ... b'},{'mychunk'}},true)
checkallerrors('load', {notastring,{nil,astring,anumber,n=3}}, 'bad argument') checkallerrors('load', {somefunction,nonstring}, 'bad argument')
checkallerrors('load', {{'return'},{afunction,atable}}, 'bad argument') checkallerrors('load', {{nil,aboolean,atable,athread},notastring}, 'bad argument')
checkallerrors('load', {{'return'},nonstring}, 'bad argument')
-- loadfile
banner('loadfile')
checkallpass('loadfile', {{'args.lua'}})
checkallerrors('loadfile', {nonstring}, 'bad argument')
-- next -- next
banner('next') banner('next')
@@ -110,15 +103,16 @@ checkallerrors('select', {notanumber}, 'bad argument')
-- setmetatable -- setmetatable
banner('setmetatable') banner('setmetatable')
checkallpass('setmetatable', {sometable,sometable}) checkallpass('setmetatable', {sometable, {nil,atable,n=2}})
checkallpass('setmetatable', {sometable,{}})
checkallerrors('setmetatable',{notatable,sometable},'bad argument') checkallerrors('setmetatable',{notatable,sometable},'bad argument')
checkallerrors('setmetatable',{sometable,nontable},'bad argument') checkallerrors('setmetatable',{sometable,nontable},'bad argument')
-- tonumber -- tonumber
banner('tonumber') banner('tonumber')
checkallpass('tonumber',{somenumber,{nil,2,10,36,n=4}}) checkallpass('tonumber',{somenumber,{nil,2,10,36,n=4}})
checkallpass('tonumber',{notanil,{nil,10,n=2}}) checkallpass('tonumber',{notanil,{nil,n=1}})
checkallpass('tonumber',{somestring,{10}})
checkallerrors('tonumber',{notastring,{10}},'bad argument')
checkallerrors('tonumber',{{nil,afunction,atable,n=3},{2,9,11,36}},'bad argument') checkallerrors('tonumber',{{nil,afunction,atable,n=3},{2,9,11,36}},'bad argument')
checkallerrors('tonumber',{somenumber,{1,37,atable,afunction,aboolean}},'bad argument') checkallerrors('tonumber',{somenumber,{1,37,atable,afunction,aboolean}},'bad argument')

View File

@@ -21,7 +21,7 @@ banner('io.lines')
io.input("abc.txt") io.input("abc.txt")
checkallpass('io.lines',{{"abc.txt"}}) checkallpass('io.lines',{{"abc.txt"}})
checkallerrors('io.lines',{{f}},'bad argument') checkallerrors('io.lines',{{f}},'bad argument')
checkallerrors('io.lines',{notastring},'bad argument') checkallerrors('io.lines',{nonstring},'bad argument')
-- io.open (filename [, mode]) -- io.open (filename [, mode])
banner('io.open') banner('io.open')
@@ -83,3 +83,7 @@ checkallerrors('file.setvbuf',{},'bad argument')
checkallerrors('file.setvbuf',{{file},notastring},'bad argument') checkallerrors('file.setvbuf',{{file},notastring},'bad argument')
checkallerrors('file.setvbuf',{{file},{"full"},nonnumber},'bad argument') checkallerrors('file.setvbuf',{{file},{"full"},nonnumber},'bad argument')
pcall( file.close, f )
os.remove("abc.txt")
pcall( file.close, file )
os.remove("seektest.txt")

View File

@@ -2,7 +2,7 @@ package.path = "?.lua;test/lua/errors/?.lua"
require 'args' require 'args'
-- arg types for language operator -- arg types for language operator
local notstringortable = { nil, anumber, aboolean, afunction, athread, n=5 }
-- ========= unary operators: - # not -- ========= unary operators: - # not
-- unary minus - -- unary minus -
@@ -15,7 +15,7 @@ checkallerrors('negative',{notanumber},'attempt to perform arithmetic')
banner('#') banner('#')
lengthop = function(a) return #a end lengthop = function(a) return #a end
checkallpass('lengthop',{sometable}) checkallpass('lengthop',{sometable})
checkallerrors('lengthop',{notatable},'attempt to get length of') checkallerrors('lengthop',{notstringortable},'attempt to get length of')
-- length -- length
banner('not') banner('not')
@@ -127,14 +127,14 @@ checkallerrors('gtop',{{astring,astrnum},notastring},'attempt to compare')
banner( '[]' ) banner( '[]' )
bracketop = function(a,b) return a[b] end bracketop = function(a,b) return a[b] end
checkallpass('bracketop',{sometable,notanil}) checkallpass('bracketop',{sometable,notanil})
checkallerrors('bracketop',{notatable,notanil},'attempt to index') checkallerrors('bracketop',{notstringortable,notanil},'attempt to index')
checkallerrors('bracketop',{sometable},'attempt to index') --checkallerrors('bracketop',{sometable},'attempt to index')
banner( '.' ) banner( '.' )
dotop = function(a,b) return a.b end dotop = function(a,b) return a.b end
checkallpass('dotop',{sometable,notanil}) checkallpass('dotop',{sometable,notanil})
checkallerrors('dotop',{notatable,notanil},'attempt to index') checkallerrors('dotop',{notstringortable,notanil},'attempt to index')
checkallerrors('dotop',{sometable},'attempt to index') --checkallerrors('dotop',{sometable},'attempt to index')
banner( 'and' ) banner( 'and' )
types = {['table']='table',['function']='function',['thread']='thread'} types = {['table']='table',['function']='function',['thread']='thread'}

View File

@@ -21,8 +21,8 @@ checkallpass('string.char',{{60},{70}})
checkallpass('string.char',{{60},{70},{80}}) checkallpass('string.char',{{60},{70},{80}})
checkallpass('string_char',{{0,9,40,127,128,255,'0','9','255','9.2',9.2}}) checkallpass('string_char',{{0,9,40,127,128,255,'0','9','255','9.2',9.2}})
checkallpass('string_char',{{0,127,255},{0,127,255}}) checkallpass('string_char',{{0,127,255},{0,127,255}})
checkallerrors('string_char',{},'bad argument') --checkallerrors('string_char',{},'bad argument')
checkallerrors('string_char',{{nil,-1,256,3}},'bad argument') checkallerrors('string_char',{{nil,-1,256}},'bad argument')
checkallerrors('string_char',{notanumber,{23,'45',6.7}},'bad argument') checkallerrors('string_char',{notanumber,{23,'45',6.7}},'bad argument')
checkallerrors('string_char',{{23,'45',6.7},nonnumber},'bad argument') checkallerrors('string_char',{{23,'45',6.7},nonnumber},'bad argument')
@@ -53,7 +53,7 @@ checkallpass('string.format',{somestring,anylua})
checkallpass('string.format',{numfmts,somenumber}) checkallpass('string.format',{numfmts,somenumber})
checkallpass('string.format',{strfmts,somestring}) checkallpass('string.format',{strfmts,somestring})
checkallerrors('string.format',{numfmts,notanumber},'bad argument') checkallerrors('string.format',{numfmts,notanumber},'bad argument')
checkallerrors('string.format',{strfmts,notastring},'bad argument') checkallerrors('string.format',{{'%q'},notastring},'bad argument')
checkallerrors('string.format',{badfmts,somestring},"invalid option '%w'") checkallerrors('string.format',{badfmts,somestring},"invalid option '%w'")
-- string.gmatch -- string.gmatch
@@ -90,7 +90,7 @@ checkallerrors('string.match',{},'bad argument')
checkallerrors('string.match',{nonstring,somestring},'bad argument') checkallerrors('string.match',{nonstring,somestring},'bad argument')
checkallerrors('string.match',{somestring},'bad argument') checkallerrors('string.match',{somestring},'bad argument')
checkallerrors('string.match',{somestring,nonstring},'bad argument') checkallerrors('string.match',{somestring,nonstring},'bad argument')
checkallerrors('string.match',{somestring,somestring,notanumber},'bad argument') checkallerrors('string.match',{somestring,somestring,nonnumber},'bad argument')
-- string.reverse -- string.reverse
banner('string.reverse') banner('string.reverse')