From 19046381ae319915c4e8fff7b108e6b5dd100509 Mon Sep 17 00:00:00 2001 From: Jim Lawson Date: Thu, 11 Feb 2016 10:34:32 -0800 Subject: Add whenever method to TblSpec forall to weed out invalid test values. --- src/test/scala/chiselTests/Tbl.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/test') 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) } + } } } } -- cgit v1.2.3