forked from MapComplete/MapComplete
Full code cleanup
This commit is contained in:
parent
8e6ee8c87f
commit
bd21212eba
246 changed files with 19418 additions and 11729 deletions
|
@ -8,28 +8,6 @@ export default class T {
|
|||
this._tests = tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* RUns the test, returns the error messages.
|
||||
* Returns an empty list if successful
|
||||
* @constructor
|
||||
*/
|
||||
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) {
|
||||
console.log("ERROR: ", e, e.stack)
|
||||
failures.push({testsuite: this.name, name: name, msg: "" + e});
|
||||
}
|
||||
}
|
||||
if (failures.length == 0) {
|
||||
return undefined
|
||||
} else {
|
||||
return failures
|
||||
}
|
||||
}
|
||||
|
||||
static assertContains(needle: string, actual: string) {
|
||||
if (actual.indexOf(needle) < 0) {
|
||||
throw `The substring ${needle} was not found`
|
||||
|
@ -57,10 +35,10 @@ export default class T {
|
|||
}
|
||||
|
||||
static listIdentical<T>(expected: T[], actual: T[]): void {
|
||||
if(expected === undefined){
|
||||
if (expected === undefined) {
|
||||
throw "ListIdentical failed: expected list is undefined"
|
||||
}
|
||||
if(actual === undefined){
|
||||
if (actual === undefined) {
|
||||
throw "ListIdentical failed: actual list is undefined"
|
||||
}
|
||||
if (expected.length !== actual.length) {
|
||||
|
@ -68,8 +46,30 @@ export default class T {
|
|||
}
|
||||
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]}`
|
||||
throw `ListIdentical failed at index ${i}: expected ${expected[i]} but got ${actual[i]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RUns the test, returns the error messages.
|
||||
* Returns an empty list if successful
|
||||
* @constructor
|
||||
*/
|
||||
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) {
|
||||
console.log("ERROR: ", e, e.stack)
|
||||
failures.push({testsuite: this.name, name: name, msg: "" + e});
|
||||
}
|
||||
}
|
||||
if (failures.length == 0) {
|
||||
return undefined
|
||||
} else {
|
||||
return failures
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue