Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test-tests/shared/src/test/scala/zio/test/GenSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,11 @@ object GenSpec extends ZIOBaseSpec {
for {
_ <- Gen.listOfN(1024)(Gen.byte).runHead
} yield assertCompletes
},
test("map of keys with small domain") {
check(Gen.mapOf(Gen.boolean, Gen.boolean)) { map =>
assert(map)(anything)
}
}
)
}
6 changes: 3 additions & 3 deletions test/shared/src/main/scala/zio/test/Gen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,15 @@ object Gen extends GenZIO with FunctionVariants with TimeVariants {
def mapOf[R, A, B](key: Gen[R, A], value: Gen[R, B])(implicit
trace: Trace
): Gen[R, Map[A, B]] =
small(mapOfN(_)(key, value))
listOf(key.zip(value)).map(_.toMap)

/**
* A sized generator of non-empty maps.
*/
def mapOf1[R, A, B](key: Gen[R, A], value: Gen[R, B])(implicit
trace: Trace
): Gen[R, Map[A, B]] =
small(mapOfN(_)(key, value), 1)
listOf1(key.zip(value)).map(_.toMap)

/**
* A generator of maps of the specified size.
Expand All @@ -593,7 +593,7 @@ object Gen extends GenZIO with FunctionVariants with TimeVariants {
def mapOfBounded[R, A, B](min: Int, max: Int)(key: Gen[R, A], value: Gen[R, B])(implicit
trace: Trace
): Gen[R, Map[A, B]] =
bounded(min, max)(mapOfN(_)(key, value))
mapOfN(min)(key, value).zipWith(listOfBounded(0, max - min)(key.zip(value)))(_ ++ _)

/**
* A sized generator that uses an exponential distribution of size values. The
Expand Down