diff options
| author | chick | 2019-12-18 10:04:13 -0800 |
|---|---|---|
| committer | chick | 2019-12-18 10:04:13 -0800 |
| commit | c720c99a75f565c8b4fbc7147d7b9daee9123d10 (patch) | |
| tree | c31784ab0dddf2db955dbe5d6e4cf2f62ef63c40 /src/test/scala/chiselTests | |
| parent | 954cc41e1349d0df6d2250d6270590340cd36e82 (diff) | |
BitPat supports whitespace and underscores, presumably for human readability.
The BitPat.parse factory though did not remove these from the returned count.
This fixes that adds whitespace and underscores to the unit tests
This is an updated vesion of Chisel PR #1069
Diffstat (limited to 'src/test/scala/chiselTests')
| -rw-r--r-- | src/test/scala/chiselTests/Decoder.scala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/test/scala/chiselTests/Decoder.scala b/src/test/scala/chiselTests/Decoder.scala index 59ad6324..44cacccc 100644 --- a/src/test/scala/chiselTests/Decoder.scala +++ b/src/test/scala/chiselTests/Decoder.scala @@ -36,8 +36,18 @@ class DecoderSpec extends ChiselPropSpec { val bitpatPair = for(seed <- Arbitrary.arbitrary[Int]) yield { val rnd = new scala.util.Random(seed) val bs = seed.toBinaryString - val bp = bs.map(if(rnd.nextBoolean) _ else "?").mkString - ("b" + bs, "b" + bp) + val bp = bs.map(if(rnd.nextBoolean) _ else "?") + + // The following randomly throws in white space and underscores which are legal and ignored. + val bpp = bp.map { a => + if (rnd.nextBoolean) { + a + } else { + a + (if (rnd.nextBoolean) "_" else " ") + } + }.mkString + + ("b" + bs, "b" + bpp) } private def nPairs(n: Int) = Gen.containerOfN[List, (String,String)](n,bitpatPair) |
