diff options
| author | Schuyler Eldridge | 2020-05-11 19:28:23 -0400 |
|---|---|---|
| committer | Schuyler Eldridge | 2020-05-13 15:57:19 -0400 |
| commit | 93c078b8469bc55cd2d33147c33e2b5421fda9d9 (patch) | |
| tree | cf9eef22ba53136a4046edd768f2bfbe39c14509 | |
| parent | d3ab7e2db66fe3a63778f427dad6c08f64695ba5 (diff) | |
Add test of {Lower, Upper}CaseNames
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
| -rw-r--r-- | src/test/scala/firrtlTests/features/LetterCaseTransformSpec.scala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/features/LetterCaseTransformSpec.scala b/src/test/scala/firrtlTests/features/LetterCaseTransformSpec.scala new file mode 100644 index 00000000..93576578 --- /dev/null +++ b/src/test/scala/firrtlTests/features/LetterCaseTransformSpec.scala @@ -0,0 +1,43 @@ +// See LICENSE for license details. + +package firrtlTests.features + +import firrtl.features.{LowerCaseNames, UpperCaseNames} + +import firrtl.{CircuitState, Parser} +import firrtl.annotations.CircuitTarget + +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class LetterCaseTransformSpec extends AnyFlatSpec with Matchers { + + class CircuitFixture { + private val input = + """|circuit Foo: + | module Foo: + | node Bar = UInt<1>(0) + | node baz = UInt<1>(0) + | node QUX = UInt<1>(0) + | node quuxQuux = UInt<1>(0) + | node QuuzQuuz = UInt<1>(0) + | node corge_corge = UInt<1>(0) + |""".stripMargin + val state = CircuitState(Parser.parse(input), Seq.empty) + } + + behavior of "LowerCaseNames" + + it should "change all names to lowercase" in new CircuitFixture { + val string = (new LowerCaseNames).execute(state).circuit.serialize + List("foo", "bar", "baz", "qux", "quuxquux", "quuzquuz", "corge_corge").foreach(string should include (_)) + } + + behavior of "UpperCaseNames" + + it should "change all names to uppercase" in new CircuitFixture { + val string = (new UpperCaseNames).execute(state).circuit.serialize + List("FOO", "BAR", "BAZ", "QUX", "QUUXQUUX", "QUUZQUUZ", "CORGE_CORGE").foreach(string should include (_)) + } + +} |
