Fix split way action, add decent tests for them (fix #171), enable split road on cyclestreets theme

This commit is contained in:
Pieter Vander Vennet 2021-10-16 02:54:22 +02:00
parent affe8237dc
commit a2aa26aafc
12 changed files with 1908 additions and 60 deletions

View file

@ -13,19 +13,19 @@ export default class T {
* Returns an empty list if successful
* @constructor
*/
public Run() : ({testsuite: string, name: string, msg: string} []) {
const failures: {testsuite: string, name: string, msg: string} [] = []
public Run(): ({ testsuite: string, name: string, msg: string } []) {
const failures: { testsuite: string, name: string, msg: string } [] = []
for (const [name, test] of this._tests) {
try {
test();
} catch (e) {
failures.push({testsuite: this.name, name: name, msg: ""+e});
failures.push({testsuite: this.name, name: name, msg: "" + e});
}
}
if (failures.length == 0) {
return undefined
} else {
return failures
return failures
}
}
@ -40,12 +40,12 @@ export default class T {
throw "Expected true, but got false: " + msg
}
}
static equals(a, b, msg?){
if(a !== b){
throw "Not the same: "+(msg??"")+"\n" +
"Expcected: "+a+"\n" +
"Got : "+b
static equals(a, b, msg?) {
if (a !== b) {
throw "Not the same: " + (msg ?? "") + "\n" +
"Expcected: " + a + "\n" +
"Got : " + b
}
}
@ -54,4 +54,21 @@ export default class T {
throw "Expected false, but got true: " + msg
}
}
static listIdentical<T>(expected: T[], actual: T[]): void {
if(expected === undefined){
throw "ListIdentical failed: expected list is undefined"
}
if(actual === undefined){
throw "ListIdentical failed: actual list is undefined"
}
if (expected.length !== actual.length) {
throw `ListIdentical failed: expected a list of length ${expected.length} but got a list of length ${actual.length}`
}
for (let i = 0; i < expected.length; i++) {
if (expected[i] !== actual[i]) {
throw `ListIdentical failed at index ${i}: expected ${expected[i]} but got ${actual[i]}`
}
}
}
}