graph.test: Show helpful output

This commit is contained in:
mindfulminun committed 2023-04-04 00:42:35 -05:00
1 parent a994700723
commit 03933f1000
1 file changed
+7 -2
+7 -2
View File
@@ -2,6 +2,7 @@ import { g1, g2, g3 } from '../tools/graph/_graph-samples.ts'
import { GraphSolver } from '../tools/graph/graph-solver.ts'
import { assertEquals } from "https://deno.land/std/testing/asserts.ts"
import { Path } from "../tools/graph/graph.ts"
import { dedent } from "../core/string.ts"
// TODO: Add more tests!
@@ -64,7 +65,11 @@ function assertPathsEqual<vData, eData>(
expectedV.forEach((v, i) => assertEquals(path?.vertices[i].id, v))
expectedE.forEach((e, i) => assertEquals(path?.edges[i].id, e))
} catch (e) {
throw Error(`Paths are different! Expected: [${expectedV.join(' -> ')}]; Actual: [${path.vertices.map(v => v.id).join(' -> ')}]`)
} catch (_e) {
throw Error(dedent`
Paths are different!
Expected: [${expectedV.join(' -> ')}]
Actual: [${path.vertices.map(v => v.id).join(' -> ')}]
`)
}
}