2021-02-20 01:45:51 +01:00
|
|
|
|
2020-08-22 17:33:08 +02:00
|
|
|
export default class T {
|
|
|
|
|
2021-02-20 01:45:51 +01:00
|
|
|
constructor(testsuite: string, tests: [string, () => void ][]) {
|
2020-08-22 17:33:08 +02:00
|
|
|
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) {
|
2021-02-20 01:45:51 +01:00
|
|
|
console.log(`All tests of ${testsuite} done!`)
|
2020-08-22 17:33:08 +02:00
|
|
|
} else {
|
2021-02-20 01:45:51 +01:00
|
|
|
console.warn(failures.length, `tests of ${testsuite} failed :(`)
|
2020-08-22 17:33:08 +02:00
|
|
|
console.log("Failed tests: ", failures.join(","))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-20 01:45:51 +01:00
|
|
|
static assertContains(needle: string, actual: string){
|
|
|
|
if(actual.indexOf(needle) < 0){
|
|
|
|
throw `The substring ${needle} was not found`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-22 17:33:08 +02:00
|
|
|
}
|