Add testing harness

This commit is contained in:
2024-03-14 10:21:44 -05:00
parent f0876825f1
commit 55ab159a85
2 changed files with 49 additions and 13 deletions

31
scripts/test.js Normal file
View File

@@ -0,0 +1,31 @@
/* Tests for prosperon */
var tests = [];
var pass = 0;
var fail = 0;
var test = function(name, fn)
{
tests.push(function() {
print(`${pass+fail}/${tests.length}: ${name} ... `);
var result = fn();
if (result) print(`pass`);
else print(`fail`);
return result;
});
}
test("Pass test", _=>1);
test("Fail test", _=>0);
say(`Testing ${tests.length} tests.`);
for (var t of tests) {
if (t())
pass++;
else
fail++;
print("\n");
}
say(`Passed ${pass} tests and failed ${fail}`);
Game.quit();