aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/NamespaceSpec.scala
blob: 4c4605b0c7597b5448c41c8ee3b38adb279fd0b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// SPDX-License-Identifier: Apache-2.0

package firrtlTests

import firrtl.Namespace
import firrtl.testutils._

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")
  }
}