diff options
| author | Jim Lawson | 2016-02-11 10:34:32 -0800 |
|---|---|---|
| committer | Andrew Waterman | 2016-04-18 22:31:25 -0700 |
| commit | 19046381ae319915c4e8fff7b108e6b5dd100509 (patch) | |
| tree | 153d3b9811fe23cdcf350d7f8c30a7c0922ab2cf /src/test | |
| parent | 84e9b70989d62e2e1d453d1c418a31c54db6fa1a (diff) | |
Add whenever method to TblSpec forall to weed out invalid test values.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/Tbl.scala | 8 |
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) } + } } } } |
