aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Magyar2020-04-14 14:06:53 -0700
committerAlbert Magyar2020-07-27 08:50:09 -0700
commit3c1a8e88844f2df41a60f5a8902b61ccf67b1382 (patch)
treed6da098882d746eb52762c070410137b7fdc2aa3 /src
parent7537bb3c18a90ee42ee367bddd90e7d90bd6c90b (diff)
Add Conditionally scoping tests to CheckSpec
* Add specific test for shadowing
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/firrtlTests/CheckSpec.scala47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/CheckSpec.scala b/src/test/scala/firrtlTests/CheckSpec.scala
index c622bde5..b49054ad 100644
--- a/src/test/scala/firrtlTests/CheckSpec.scala
+++ b/src/test/scala/firrtlTests/CheckSpec.scala
@@ -352,6 +352,53 @@ class CheckSpec extends AnyFlatSpec with Matchers {
}
}
+ "Conditionally statements" should "create a new scope" in {
+ val input =
+ s"""|circuit scopes:
+ | module scopes:
+ | input i: UInt<1>
+ | output o: UInt<1>
+ | when i:
+ | node x = not(i)
+ | o <= and(x, i)
+ |""".stripMargin
+ assertThrows[CheckHighForm.UndeclaredReferenceException] {
+ checkHighInput(input)
+ }
+ }
+
+ "Attempting to shadow a component name" should "throw an error" in {
+ val input =
+ s"""|circuit scopes:
+ | module scopes:
+ | input i: UInt<1>
+ | output o: UInt<1>
+ | wire x: UInt<1>
+ | when i:
+ | node x = not(i)
+ | o <= and(x, i)
+ |""".stripMargin
+ assertThrows[CheckHighForm.NotUniqueException] {
+ checkHighInput(input)
+ }
+ }
+
+ "Conditionally statements" should "create separate consequent and alternate scopes" in {
+ val input =
+ s"""|circuit scopes:
+ | module scopes:
+ | input i: UInt<1>
+ | output o: UInt<1>
+ | o <= i
+ | when i:
+ | node x = not(i)
+ | else:
+ | o <= and(x, i)
+ |""".stripMargin
+ assertThrows[CheckHighForm.UndeclaredReferenceException] {
+ checkHighInput(input)
+ }
+ }
}
object CheckSpec {