summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Lawson2016-02-11 10:34:32 -0800
committerAndrew Waterman2016-04-18 22:31:25 -0700
commit19046381ae319915c4e8fff7b108e6b5dd100509 (patch)
tree153d3b9811fe23cdcf350d7f8c30a7c0922ab2cf
parent84e9b70989d62e2e1d453d1c418a31c54db6fa1a (diff)
Add whenever method to TblSpec forall to weed out invalid test values.
-rw-r--r--src/test/scala/chiselTests/Tbl.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/test/scala/chiselTests/Tbl.scala b/src/test/scala/chiselTests/Tbl.scala
index bf1201ec..7ffa24ed 100644
--- a/src/test/scala/chiselTests/Tbl.scala
+++ b/src/test/scala/chiselTests/Tbl.scala
@@ -51,8 +51,12 @@ class TblTester(w: Int, n: Int, idxs: List[Int], values: List[Int]) extends Basi
class TblSpec extends ChiselPropSpec {
property("All table reads should return the previous write") {
forAll(safeUIntPairN(8)) { case(w: Int, pairs: List[(Int, Int)]) =>
- val (idxs, values) = pairs.unzip
- assertTesterPasses{ new TblTester(w, 1 << w, idxs, values) }
+ // Provide an appropriate whenever clause.
+ // ScalaTest will try and shrink the values on error to determine the smallest values that cause the error.
+ whenever(w > 0 && pairs.length > 0) {
+ val (idxs, values) = pairs.unzip
+ assertTesterPasses{ new TblTester(w, 1 << w, idxs, values) }
+ }
}
}
}