Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ class AmberFIFOChannel(val channelId: ChannelIdentity) extends AmberLogging {
}

def getPortId: PortIdentity = {
this.portId.get
this.portId.getOrElse(
throw new IllegalStateException(
s"portId has not been set for channel $channelId; call setPortId before getPortId"
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ class AmberFIFOChannelSpec extends AnyFlatSpec {
// PortId association
// ---------------------------------------------------------------------------

"AmberFIFOChannel.getPortId" should "throw when no portId has been set" in {
"AmberFIFOChannel.getPortId" should "throw IllegalStateException with a descriptive message when no portId has been set" in {
val ch = new AmberFIFOChannel(cid)
// Option.get on None
assertThrows[NoSuchElementException] {
val ex = intercept[IllegalStateException] {
ch.getPortId
}
assert(ex.getMessage.contains("portId has not been set"))
assert(ex.getMessage.contains(cid.toString))
}

it should "return the most recently configured portId" in {
Expand Down
Loading