diff options
| author | Albert Magyar | 2017-02-26 16:11:37 -0800 |
|---|---|---|
| committer | Albert Magyar | 2017-03-17 14:26:44 -0700 |
| commit | 13fc27f35e85026c002e644b61c32268bd258d78 (patch) | |
| tree | 2c3a36c3d7fa8c7bf44c2a48ac7218c539bafac6 /src/test | |
| parent | 3608401852baa18b4deaa22669529830b751901a (diff) | |
Add utilites for digraphs and netlist analyses
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/graph/DiGraphTests.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/graph/DiGraphTests.scala b/src/test/scala/firrtlTests/graph/DiGraphTests.scala new file mode 100644 index 00000000..6546e147 --- /dev/null +++ b/src/test/scala/firrtlTests/graph/DiGraphTests.scala @@ -0,0 +1,38 @@ +package firrtlTests.graph + +import java.io._ +import org.scalatest._ +import org.scalatest.prop._ +import org.scalatest.Matchers._ +import firrtl.graph._ +import firrtlTests._ + +class DiGraphTests extends FirrtlFlatSpec { + + val acyclicGraph = DiGraph(Map( + "a" -> Set("b","c"), + "b" -> Set("d"), + "c" -> Set("d"), + "d" -> Set("e"), + "e" -> Set.empty[String])) + + val cyclicGraph = DiGraph(Map( + "a" -> Set("b","c"), + "b" -> Set("d"), + "c" -> Set("d"), + "d" -> Set("a"))) + + + acyclicGraph.findSCCs.filter(_.length > 1) shouldBe empty + + cyclicGraph.findSCCs.filter(_.length > 1) should not be empty + + acyclicGraph.path("a","e") should not be empty + + an [acyclicGraph.PathNotFoundException] should be thrownBy acyclicGraph.path("e","a") + + acyclicGraph.linearize.head should equal ("a") + + a [cyclicGraph.CyclicException] should be thrownBy cyclicGraph.linearize + +} |
