mapcomplete/test/TestHelper.ts
2020-10-06 01:37:02 +02:00

21 lines
592 B
TypeScript

export default class T {
constructor(tests: [string, () => void ][]) {
let failures : string []= [];
for (const [name, test] of tests) {
try {
test();
} catch (e) {
failures.push(name);
console.warn("Failed test: ", name, "because", e);
}
}
if (failures.length == 0) {
console.log("All tests done!")
} else {
console.warn(failures.length, "tests failed :(")
console.log("Failed tests: ", failures.join(","))
}
}
}