From c720c99a75f565c8b4fbc7147d7b9daee9123d10 Mon Sep 17 00:00:00 2001 From: chick Date: Wed, 18 Dec 2019 10:04:13 -0800 Subject: 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 --- src/test/scala/chiselTests/Decoder.scala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/test') 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) -- cgit v1.2.3