Skip to content

Commit

Permalink
Add positive range generator
Browse files Browse the repository at this point in the history
  • Loading branch information
nullobject committed Jul 15, 2020
1 parent 9dda7f5 commit 8fab4d6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/test/scala/chiselTests/ChiselSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ class ChiselPropSpec extends PropSpec with ChiselRunners with ScalaCheckProperty
// Generator for small positive integers.
val smallPosInts = Gen.choose(1, 4)

// Generator for positive (ascending or descending) ranges.
def posRange: Gen[Range] = for {
dir <- Gen.oneOf(true, false)
step <- Gen.choose(1, 3)
m <- Gen.choose(1, 10)
n <- Gen.choose(1, 10)
} yield {
if (dir) {
Range(m, (m+n)*step, step)
} else {
Range((m+n)*step, m, -step)
}
}

// Generator for widths considered "safe".
val safeUIntWidth = Gen.choose(1, 30)

Expand Down

0 comments on commit 8fab4d6

Please sign in to comment.