prosperon/scripts/test.js

39 lines
709 B
JavaScript
Raw Normal View History

2024-03-14 10:21:44 -05:00
/* Tests for prosperon */
var tests = [];
var pass = 0;
var fail = 0;
var failed = [];
2024-03-14 10:21:44 -05:00
var test = function(name, fn)
{
var func = function() {
print(`${pass+fail+1}/${tests.length}: ${name} ... `);
var p = profile.now();
var b = fn();
p = profile.lap(p);
print(`${b ? "pass" : "fail"} [${p}]`);
return b;
};
func.testname = name;
tests.push(func);
2024-03-14 10:21:44 -05:00
}
say(`Testing ${tests.length} tests.`);
for (var t of tests) {
if (t())
pass++;
else {
2024-03-14 10:21:44 -05:00
fail++;
failed.push(t.testname);
}
2024-03-14 10:21:44 -05:00
print("\n");
}
say(`Passed ${pass} tests and failed ${fail} [${(pass*100/(pass+fail)).toPrecision(4)}%].`);
say(`Failed tests are:`);
for (var f of failed)
say(f);
Game.quit();