Choose

object Choose extends JavaTimeChoose

Provides implicit org.scalacheck.Gen.Choose instances

Provides implicit org.scalacheck.Gen.Choose instances

Companion
class
trait JavaTimeChoose
class Object
trait Matchable
class Any

Type members

Classlikes

class IllegalBoundsError[A](low: A, high: A) extends IllegalArgumentException
object chooseBigInt extends Choose[BigInt]
object chooseBigInteger extends Choose[BigInteger]

Value members

Concrete methods

def xmap[T, U](from: T => U, to: U => T)(c: Choose[T]): Choose[U]

Transform a Choose[T] to a Choose[U] where T and U are two isomorphic types whose relationship is described by the provided transformation functions. (exponential functor map)

Transform a Choose[T] to a Choose[U] where T and U are two isomorphic types whose relationship is described by the provided transformation functions. (exponential functor map)

Implicits

Implicits

implicit val chooseBigDecimal: Choose[BigDecimal]

Choose a BigDecimal number between two given numbers.

Choose a BigDecimal number between two given numbers.

The minimum scale used will be 34. That means that the fractional part will have at least 34 digits (more if one of the given numbers has a scale larger than 34).

The minimum scale was chosen based on Scala's default scale for expanding infinite fractions:

BigDecimal(1) / 3 // 0.3333333333333333333333333333333333

See chooseBigDecimalScale for more information about scale.

implicit val chooseByte: Choose[Byte]
implicit val chooseChar: Choose[Char]
implicit val chooseDouble: Choose[Double]
implicit val chooseFiniteDuration: Choose[FiniteDuration]
implicit val chooseFloat: Choose[Float]
implicit val chooseInt: Choose[Int]
implicit val chooseJavaBigDecimal: Choose[BigDecimal]

Choose a java.math.BigDecimal number between two given numbers.

Choose a java.math.BigDecimal number between two given numbers.

See chooseBigDecimal and chooseBigDecimalScale for more comments.

implicit val chooseLong: Choose[Long]
implicit val chooseShort: Choose[Short]

Inherited implicits

final implicit lazy val chooseInstant: Choose[Instant]
Inherited from
JavaTimeChoose
final implicit lazy val chooseJavaDuration: Choose[Duration]
Inherited from
JavaTimeChoose
final implicit lazy val chooseLocalDate: Choose[LocalDate]
Inherited from
JavaTimeChoose
final implicit lazy val chooseLocalDateTime: Choose[LocalDateTime]
Inherited from
JavaTimeChoose
final implicit lazy val chooseLocalTime: Choose[LocalTime]
Inherited from
JavaTimeChoose
final implicit lazy val chooseMonth: Choose[Month]
Inherited from
JavaTimeChoose
final implicit lazy val chooseMonthDay: Choose[MonthDay]
Inherited from
JavaTimeChoose
final implicit lazy val chooseOffsetDateTime: Choose[OffsetDateTime]
Inherited from
JavaTimeChoose
final implicit lazy val chooseOffsetTime: Choose[OffsetTime]
Inherited from
JavaTimeChoose
final implicit lazy val chooseYear: Choose[Year]
Inherited from
JavaTimeChoose
final implicit lazy val chooseYearMonth: Choose[YearMonth]
Inherited from
JavaTimeChoose
final implicit lazy val chooseZoneOffset: Choose[ZoneOffset]

ZoneOffset values have some unusual semantics when it comes to ordering. The short explanation is that (ZoneOffset.MAX < ZoneOffset.MIN) == true. This is because for any given LocalDateTime, that time applied to ZoneOffset.MAX will be an older moment in time than that same LocalDateTime applied to ZoneOffset.MIN.

ZoneOffset values have some unusual semantics when it comes to ordering. The short explanation is that (ZoneOffset.MAX < ZoneOffset.MIN) == true. This is because for any given LocalDateTime, that time applied to ZoneOffset.MAX will be an older moment in time than that same LocalDateTime applied to ZoneOffset.MIN.

From the JavaDoc,

"The offsets are compared in the order that they occur for the same time of day around the world. Thus, an offset of +10:00 comes before an offset of +09:00 and so on down to -18:00."

This has the following implication,

scala> ZoneOffset.MIN
val res0: java.time.ZoneOffset = -18:00

scala> ZoneOffset.MAX
val res1: java.time.ZoneOffset = +18:00

scala> ZoneOffset.MIN.compareTo(ZoneOffset.MAX)
val res3: Int = 129600

This implementation is consistent with that comparison.

See also
Inherited from
JavaTimeChoose
final implicit lazy val chooseZonedDateTime: Choose[ZonedDateTime]
Inherited from
JavaTimeChoose