From cd8542d31f20511844c59e08527af73d1e3f6ae1 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Fri, 29 Sep 2017 15:12:43 -0700 Subject: Namespace - only save suffix for temp names (#667) This prevents collisions for one prefix (including temp) from incrementing the suffix for other prefixes. Makes names more stable.--- src/test/scala/firrtlTests/NamespaceSpec.scala | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/scala/firrtlTests/NamespaceSpec.scala (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/NamespaceSpec.scala b/src/test/scala/firrtlTests/NamespaceSpec.scala new file mode 100644 index 00000000..8aa29705 --- /dev/null +++ b/src/test/scala/firrtlTests/NamespaceSpec.scala @@ -0,0 +1,26 @@ +// See LICENSE for license details. + +package firrtlTests + +import firrtl.Namespace + +class NamespaceSpec extends FirrtlFlatSpec { + + "A Namespace" should "not allow collisions" in { + val namespace = Namespace() + namespace.newName("foo") should be ("foo") + namespace.newName("foo") should be ("foo_0") + } + + it should "start temps with a suffix of 0" in { + Namespace().newTemp.last should be ('0') + } + + it should "handle multiple prefixes with independent suffixes" in { + val namespace = Namespace() + namespace.newName("foo") should be ("foo") + namespace.newName("foo") should be ("foo_0") + namespace.newName("bar") should be ("bar") + namespace.newName("bar") should be ("bar_0") + } +} -- cgit v1.2.3