aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSchuyler Eldridge2018-09-25 12:25:05 -0400
committerSchuyler Eldridge2018-09-26 17:25:24 -0400
commit502c8dd35e6f27ed6794dad7ae9bcf4d41cc7474 (patch)
treeb1000d59ec709a548614a8ebac65ea76d77e603b /src/test
parentba12915e9b93685107c503b3f91b96d491c48459 (diff)
Enforce port uniqueness in Chirrtl/High Checks
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/CheckSpec.scala28
-rw-r--r--src/test/scala/firrtlTests/ChirrtlSpec.scala11
2 files changed, 38 insertions, 1 deletions
diff --git a/src/test/scala/firrtlTests/CheckSpec.scala b/src/test/scala/firrtlTests/CheckSpec.scala
index 3c9894ba..767f2392 100644
--- a/src/test/scala/firrtlTests/CheckSpec.scala
+++ b/src/test/scala/firrtlTests/CheckSpec.scala
@@ -282,4 +282,32 @@ class CheckSpec extends FlatSpec with Matchers {
}
}
}
+
+ behavior of "Uniqueness"
+ for ((description, input) <- CheckSpec.nonUniqueExamples) {
+ it should s"be asserted for $description" in {
+ assertThrows[CheckHighForm.NotUniqueException] {
+ Seq(ToWorkingIR, CheckHighForm).foldLeft(Parser.parse(input)){ case (c, tx) => tx.run(c) }
+ }
+ }
+ }
}
+
+object CheckSpec {
+ val nonUniqueExamples = List(
+ ("two ports with the same name",
+ """|circuit Top:
+ | module Top:
+ | input a: UInt<1>
+ | input a: UInt<1>""".stripMargin),
+ ("two nodes with the same name",
+ """|circuit Top:
+ | module Top:
+ | node a = UInt<1>("h0")
+ | node a = UInt<1>("h0")""".stripMargin),
+ ("a port and a node with the same name",
+ """|circuit Top:
+ | module Top:
+ | input a: UInt<1>
+ | node a = UInt<1>("h0") """.stripMargin) )
+ }
diff --git a/src/test/scala/firrtlTests/ChirrtlSpec.scala b/src/test/scala/firrtlTests/ChirrtlSpec.scala
index fd4374f0..774c352b 100644
--- a/src/test/scala/firrtlTests/ChirrtlSpec.scala
+++ b/src/test/scala/firrtlTests/ChirrtlSpec.scala
@@ -16,7 +16,7 @@ class ChirrtlSpec extends FirrtlFlatSpec {
CInferTypes,
CInferMDir,
RemoveCHIRRTL,
- ToWorkingIR,
+ ToWorkingIR,
CheckHighForm,
ResolveKinds,
InferTypes,
@@ -71,6 +71,15 @@ class ChirrtlSpec extends FirrtlFlatSpec {
}
}
}
+
+ behavior of "Uniqueness"
+ for ((description, input) <- CheckSpec.nonUniqueExamples) {
+ it should s"be asserted for $description" in {
+ assertThrows[CheckChirrtl.NotUniqueException] {
+ Seq(ToWorkingIR, CheckChirrtl).foldLeft(Parser.parse(input)){ case (c, tx) => tx.run(c) }
+ }
+ }
+ }
}
class ChirrtlMemsExecutionTest extends ExecutionTest("ChirrtlMems", "/features")