summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Koenig2017-12-22 09:30:21 -0800
committerGitHub2017-12-22 09:30:21 -0800
commitcb7fcd2b18135230dc40f3c7bb98685e7ffde9d5 (patch)
tree6b268520c6dcc9b91129d07017e9713d143e6149 /src
parent08dfb23c97ee8cd0a01e51511fcd156a7da61c02 (diff)
Fixes format strings in assertions. Fixes #540 (#542)
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/chiselTests/Assert.scala21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/test/scala/chiselTests/Assert.scala b/src/test/scala/chiselTests/Assert.scala
index 994a16fd..075cc4e2 100644
--- a/src/test/scala/chiselTests/Assert.scala
+++ b/src/test/scala/chiselTests/Assert.scala
@@ -46,7 +46,18 @@ class PipelinedResetTester extends BasicTester {
class ModuloAssertTester extends BasicTester {
assert((4.U % 2.U) === 0.U)
- assert(1.U === 1.U, "I'm 110% sure this will succeed")
+ stop()
+}
+
+class FormattedAssertTester extends BasicTester {
+ val foobar = Wire(UInt(32.W))
+ foobar := 123.U
+ assert(foobar === 123.U, "Error! Wire foobar =/= %x! This is 100%% wrong.\n", foobar)
+ stop()
+}
+
+class BadUnescapedPercentAssertTester extends BasicTester {
+ assert(1.U === 1.U, "I'm 110% sure this is an invalid message")
stop()
}
@@ -63,4 +74,12 @@ class AssertSpec extends ChiselFlatSpec {
"Assertions" should "allow the modulo operator % in the message" in {
assertTesterPasses{ new ModuloAssertTester }
}
+ they should "allow printf-style format strings with arguments" in {
+ assertTesterPasses{ new FormattedAssertTester }
+ }
+ they should "not allow unescaped % in the message" in {
+ a [java.util.UnknownFormatConversionException] should be thrownBy {
+ elaborate { new BadUnescapedPercentAssertTester }
+ }
+ }
}