Merge develop
This commit is contained in:
commit
94f66eafc1
56 changed files with 2336 additions and 832 deletions
|
@ -362,6 +362,85 @@ export default class GeoOperationsSpec extends T {
|
|||
const overlapsRev = GeoOperations.calculateOverlap(polyHouse, [polyGrb])
|
||||
Assert.equal(overlapsRev.length, 0)
|
||||
|
||||
}],
|
||||
["Overnode removal test", () => {
|
||||
|
||||
const feature = { "geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
4.477944199999975,
|
||||
51.02783550000022
|
||||
],
|
||||
[
|
||||
4.477987899999996,
|
||||
51.027818800000034
|
||||
],
|
||||
[
|
||||
4.478004500000021,
|
||||
51.02783399999988
|
||||
],
|
||||
[
|
||||
4.478025499999962,
|
||||
51.02782489999994
|
||||
],
|
||||
[
|
||||
4.478079099999993,
|
||||
51.027873899999896
|
||||
],
|
||||
[
|
||||
4.47801040000006,
|
||||
51.027903799999955
|
||||
],
|
||||
[
|
||||
4.477964799999972,
|
||||
51.02785709999982
|
||||
],
|
||||
[
|
||||
4.477964699999964,
|
||||
51.02785690000006
|
||||
],
|
||||
[
|
||||
4.477944199999975,
|
||||
51.02783550000022
|
||||
]
|
||||
]
|
||||
]
|
||||
}}
|
||||
|
||||
const copy = GeoOperations.removeOvernoding(feature)
|
||||
Assert.equal(copy.geometry.coordinates[0].length, 7)
|
||||
T.listIdentical([
|
||||
[
|
||||
4.477944199999975,
|
||||
51.02783550000022
|
||||
],
|
||||
[
|
||||
4.477987899999996,
|
||||
51.027818800000034
|
||||
],
|
||||
[
|
||||
4.478004500000021,
|
||||
51.02783399999988
|
||||
],
|
||||
[
|
||||
4.478025499999962,
|
||||
51.02782489999994
|
||||
],
|
||||
[
|
||||
4.478079099999993,
|
||||
51.027873899999896
|
||||
],
|
||||
[
|
||||
4.47801040000006,
|
||||
51.027903799999955
|
||||
],
|
||||
[
|
||||
4.477944199999975,
|
||||
51.02783550000022
|
||||
]
|
||||
], copy.geometry.coordinates[0])
|
||||
}]
|
||||
]
|
||||
)
|
||||
|
|
File diff suppressed because one or more lines are too long
111
test/TestAll.ts
111
test/TestAll.ts
|
@ -17,59 +17,66 @@ import ReplaceGeometrySpec from "./ReplaceGeometry.spec";
|
|||
import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec";
|
||||
|
||||
|
||||
ScriptUtils.fixUtils()
|
||||
const allTests = [
|
||||
new OsmObjectSpec(),
|
||||
new TagSpec(),
|
||||
new ImageAttributionSpec(),
|
||||
new GeoOperationsSpec(),
|
||||
new ThemeSpec(),
|
||||
new UtilsSpec(),
|
||||
new UnitsSpec(),
|
||||
new RelationSplitHandlerSpec(),
|
||||
new SplitActionSpec(),
|
||||
new TileFreshnessCalculatorSpec(),
|
||||
new WikidataSpecTest(),
|
||||
new ImageProviderSpec(),
|
||||
new ActorsSpec(),
|
||||
new ReplaceGeometrySpec(),
|
||||
new LegacyThemeLoaderSpec()
|
||||
]
|
||||
async function main() {
|
||||
|
||||
Utils.externalDownloadFunction = async (url) => {
|
||||
console.error("Fetching ", url, "blocked in tests, use Utils.injectJsonDownloadForTests")
|
||||
const data = await ScriptUtils.DownloadJSON(url)
|
||||
console.log("\n\n ----------- \nBLOCKED DATA\n Utils.injectJsonDownloadForTests(\n" +
|
||||
" ", JSON.stringify(url), ", \n",
|
||||
" ", JSON.stringify(data), "\n )\n------------------\n\n")
|
||||
throw "Detected internet access for URL " + url + ", please inject it with Utils.injectJsonDownloadForTests"
|
||||
}
|
||||
ScriptUtils.fixUtils()
|
||||
const allTests = [
|
||||
new OsmObjectSpec(),
|
||||
new TagSpec(),
|
||||
new ImageAttributionSpec(),
|
||||
new GeoOperationsSpec(),
|
||||
new ThemeSpec(),
|
||||
new UtilsSpec(),
|
||||
new UnitsSpec(),
|
||||
new RelationSplitHandlerSpec(),
|
||||
new SplitActionSpec(),
|
||||
new TileFreshnessCalculatorSpec(),
|
||||
new WikidataSpecTest(),
|
||||
new ImageProviderSpec(),
|
||||
new ActorsSpec(),
|
||||
new ReplaceGeometrySpec(),
|
||||
new LegacyThemeLoaderSpec()
|
||||
]
|
||||
|
||||
let args = [...process.argv]
|
||||
args.splice(0, 2)
|
||||
args = args.map(a => a.toLowerCase())
|
||||
|
||||
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
||||
let testsToRun = allTests
|
||||
if (args.length > 0) {
|
||||
args = args.map(a => a.toLowerCase())
|
||||
testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0)
|
||||
}
|
||||
|
||||
if (testsToRun.length == 0) {
|
||||
throw "No tests found. Try one of " + allTests.map(t => t.name).join(", ")
|
||||
}
|
||||
|
||||
for (let i = 0; i < testsToRun.length; i++) {
|
||||
const test = testsToRun[i];
|
||||
console.log(" Running test", i, "/", testsToRun.length, test.name)
|
||||
allFailures.push(...(test.Run() ?? []))
|
||||
console.log("OK!")
|
||||
}
|
||||
if (allFailures.length > 0) {
|
||||
for (const failure of allFailures) {
|
||||
console.error(" !! " + failure.testsuite + "." + failure.name + " failed due to: " + failure.msg)
|
||||
Utils.externalDownloadFunction = async (url) => {
|
||||
console.error("Fetching ", url, "blocked in tests, use Utils.injectJsonDownloadForTests")
|
||||
const data = await ScriptUtils.DownloadJSON(url)
|
||||
console.log("\n\n ----------- \nBLOCKED DATA\n Utils.injectJsonDownloadForTests(\n" +
|
||||
" ", JSON.stringify(url), ", \n",
|
||||
" ", JSON.stringify(data), "\n )\n------------------\n\n")
|
||||
throw "Detected internet access for URL " + url + ", please inject it with Utils.injectJsonDownloadForTests"
|
||||
}
|
||||
throw "Some test failed"
|
||||
|
||||
let args = [...process.argv]
|
||||
args.splice(0, 2)
|
||||
args = args.map(a => a.toLowerCase())
|
||||
|
||||
const allFailures: { testsuite: string, name: string, msg: string } [] = []
|
||||
let testsToRun = allTests
|
||||
if (args.length > 0) {
|
||||
args = args.map(a => a.toLowerCase())
|
||||
testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0)
|
||||
}
|
||||
|
||||
if (testsToRun.length == 0) {
|
||||
throw "No tests found. Try one of " + allTests.map(t => t.name).join(", ")
|
||||
}
|
||||
|
||||
for (let i = 0; i < testsToRun.length; i++) {
|
||||
const test = testsToRun[i];
|
||||
console.log(" Running test", i, "/", testsToRun.length, test.name)
|
||||
|
||||
allFailures.push(...(await test.Run() ?? []))
|
||||
console.log("OK!")
|
||||
}
|
||||
if (allFailures.length > 0) {
|
||||
for (const failure of allFailures) {
|
||||
console.error(" !! " + failure.testsuite + "." + failure.name + " failed due to: " + failure.msg)
|
||||
}
|
||||
throw "Some test failed"
|
||||
}
|
||||
console.log("All tests successful: ", testsToRun.map(t => t.name).join(", "))
|
||||
|
||||
}
|
||||
console.log("All tests successful: ", testsToRun.map(t => t.name).join(", "))
|
||||
|
||||
main()
|
|
@ -45,7 +45,9 @@ export default class T {
|
|||
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]) {
|
||||
if(expected[i] !== undefined && expected[i]["length"] !== undefined ){
|
||||
T.listIdentical(<any> expected[i], <any> actual[i])
|
||||
}else if (expected[i] !== actual[i]) {
|
||||
throw `ListIdentical failed at index ${i}: expected ${expected[i]} but got ${actual[i]}`
|
||||
}
|
||||
}
|
||||
|
@ -56,16 +58,18 @@ export default class T {
|
|||
* Returns an empty list if successful
|
||||
* @constructor
|
||||
*/
|
||||
public Run(): { testsuite: string, name: string, msg: string } [] {
|
||||
public async Run(): Promise<{ testsuite: string, name: string, msg: string } []> {
|
||||
const failures: { testsuite: string, name: string, msg: string } [] = []
|
||||
for (const [name, test] of this._tests) {
|
||||
try {
|
||||
const r = test()
|
||||
if (r instanceof Promise) {
|
||||
r.catch(e => {
|
||||
try {
|
||||
await r
|
||||
} catch (e) {
|
||||
console.log("ASYNC ERROR: ", e, e.stack)
|
||||
failures.push({testsuite: this.name, name: name, msg: "" + e});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue