aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJack Koenig2017-07-14 15:44:39 -0700
committerGitHub2017-07-14 15:44:39 -0700
commit661147d84d8c27a5b4f051ced12ebf7efecb40dc (patch)
tree1c1aa6d11b16c8df024430d8b0d1351aa51ff4f6 /src/test
parent49fca68c4f01b4fee6e9ebb9b4fae00dd349c5f4 (diff)
Fix bug in DiGraph.reverse on an graph with one vertex, no edges (#628)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/graph/DiGraphTests.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/graph/DiGraphTests.scala b/src/test/scala/firrtlTests/graph/DiGraphTests.scala
index 6546e147..9eb1c7f8 100644
--- a/src/test/scala/firrtlTests/graph/DiGraphTests.scala
+++ b/src/test/scala/firrtlTests/graph/DiGraphTests.scala
@@ -16,12 +16,20 @@ class DiGraphTests extends FirrtlFlatSpec {
"d" -> Set("e"),
"e" -> Set.empty[String]))
+ val reversedAcyclicGraph = DiGraph(Map(
+ "a" -> Set.empty[String],
+ "b" -> Set("a"),
+ "c" -> Set("a"),
+ "d" -> Set("b", "c"),
+ "e" -> Set("d")))
+
val cyclicGraph = DiGraph(Map(
"a" -> Set("b","c"),
"b" -> Set("d"),
"c" -> Set("d"),
"d" -> Set("a")))
+ val degenerateGraph = DiGraph(Map("a" -> Set.empty[String]))
acyclicGraph.findSCCs.filter(_.length > 1) shouldBe empty
@@ -35,4 +43,8 @@ class DiGraphTests extends FirrtlFlatSpec {
a [cyclicGraph.CyclicException] should be thrownBy cyclicGraph.linearize
+ acyclicGraph.reverse.edges should equal (reversedAcyclicGraph.edges)
+
+ degenerateGraph.edges should equal (degenerateGraph.reverse.edges)
+
}