Add mocule argument type checking.

This commit is contained in:
James Roseborough
2008-07-15 23:58:15 +00:00
parent 07b9297adc
commit 8f209948f5
2 changed files with 36 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
package.path = "?.lua;src/test/errors/?.lua"
require 'args'
-- arg type tests for module library functions
-- require
banner('require')
checkallpass('require',{{'math'}})
checkallerrors('require',{{anumber}},'not found')
checkallerrors('require',{{anil,aboolean,afunction,atable}},'bad argument')
-- package.loadlib
banner('package.loadlib')
checkallpass('package.loadlib',{{'foo'},{'bar'}})
checkallerrors('package.loadlib',{notastring},'bad argument')
-- package.seeall
banner('package.seeall')
checkallpass('package.seeall',{sometable})
checkallerrors('package.seeall',{notatable},'bad argument')
-- module (last because it pretty much breaks this chunk)
print( pcall( function()
banner('module')
checkallpass('module',{somestrnum,{package.seeall},{nil,afunction}})
checkallerrors('module',{{aboolean,atable,afunction}},'bad argument')
checkallerrors('module',{{aboolean,atable,afunction},{package.seeall}},'bad argument')
checkallerrors('module',{somestring,{astring,anumber,aboolean,atable}},'attempt to call a')
end ) )

View File

@@ -16,7 +16,12 @@ public class ErrorMessageTest extends ScriptDrivenTest {
public void testBaseLibArgs() throws IOException, InterruptedException {
runTest("baselibargs");
}
public void testCoroutineLibArgs() throws IOException, InterruptedException {
runTest("coroutinelibargs");
}
public void testModuleLibArgs() throws IOException, InterruptedException {
runTest("modulelibargs");
}
}