aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSchuyler Eldridge2020-05-13 16:42:51 -0400
committerGitHub2020-05-13 16:42:51 -0400
commit8528422809fce49a44d7a8e548911bc280677150 (patch)
treecf9eef22ba53136a4046edd768f2bfbe39c14509 /src/test
parent498b833aa5f44a9b998d4b93edf9495c0498e0cd (diff)
parent93c078b8469bc55cd2d33147c33e2b5421fda9d9 (diff)
Merge pull request #1592 from freechipsproject/generalize-keyword-collision-to-name-manipulation
Generalize keyword collision to name manipulation, Add {Lower,Upper}CaseNames Transforms
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/features/LetterCaseTransformSpec.scala43
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 (_))
+ }
+
+}