The file is part of the BURN project (learing multi-objective rules).
Because learning is not the filling a pail, but the lighting of a fire.
require "burn"
Burn.sys.tests={try=0, fail=0}
local match = require("lib").match
local my=Burn.sys.tests
local Test={}
function Test.report()
local n= 1-((my.try-my.fail)/my.try)
print("-- Failures: ".. 100*n .. "%")
end
function Test.ok(t)
Test.rogues()
for x,f in pairs(t) do
print("-- Checking ".. x .."... ")
my.try = my.try + 1
local passed,err = pcall(f)
if not passed then
my.fail = my.fail+1
print("-- E> Failure: " .. err)
Test.report() end end
end
function Test.rogues()
local ignore = {
jit=true, math=true, package=true, table=true, coroutine=true,
bit=true, os=true, io=true, bit32=true, string=true,
arg=true, debug=true, _VERSION=true, _G=true }
for k,v in pairs( _G ) do
if type(v) ~= "function" and not ignore[k] then
assert(match(k,"^[A-Z]"),"rogue local ["..k.."]") end end
end
return Test