Files
luaj/test/lua/errors/modulelibargs.lua

50 lines
1.6 KiB
Lua
Raw Normal View History

2008-07-15 23:58:15 +00:00
package.path = "?.lua;src/test/errors/?.lua"
require 'args'
-- arg type tests for module library functions
-- require
banner('require')
2008-07-22 22:32:28 +00:00
checkallpass('require',{{'math','coroutine','package','string','table'}},true)
2008-07-15 23:58:15 +00:00
checkallerrors('require',{{anumber}},'not found')
checkallerrors('require',{{anil,aboolean,afunction,atable}},'bad argument')
-- package.loadlib
banner('package.loadlib')
2008-07-22 22:32:28 +00:00
checkallpass('package.loadlib',{{'foo'},{'bar'}},true)
2008-07-15 23:58:15 +00:00
checkallerrors('package.loadlib',{notastring},'bad argument')
-- package.seeall
banner('package.seeall')
checkallpass('package.seeall',{sometable})
checkallerrors('package.seeall',{notatable},'bad argument')
2008-07-22 22:32:28 +00:00
-- module tests - require special rigging
banner('module')
2008-07-15 23:58:15 +00:00
print( pcall( function()
2008-07-22 22:32:28 +00:00
checkallpass('module',{{20001}})
end ) )
print( pcall( function()
checkallpass('module',{{20002},{package.seeall}})
end ) )
print( pcall( function()
checkallpass('module',{{20003},{package.seeall},{function() end}})
end ) )
print( pcall( function()
checkallerrors('module',{{aboolean,atable,function() end}},'bad argument')
checkallerrors('module',{{aboolean,atable,function() end},{package.seeall}},'bad argument')
end ) )
print( pcall( function()
checkallerrors('module',{{'testmodule1'},{'pqrs'}},'attempt to call')
end ) )
print( pcall( function()
checkallerrors('module',{{'testmodule2'},{aboolean}},'attempt to call')
end ) )
print( pcall( function()
checkallerrors('module',{{'testmodule3'},{athread}},'attempt to call')
end ) )
print( pcall( function()
checkallerrors('module',{{'testmodule4'},{atable}},'attempt to call')
2008-07-15 23:58:15 +00:00
end ) )