theiterators/kebs

kebs-scalacheck - generators do not pull opaque type Arbitrary instances defined by user

Closed this issue · 1 comments

pk044 commented
object TokenUsdPriceDomain:
  opaque type TokenUsdPriceTimestamp = Instant
  object TokenUsdPriceTimestamp extends Opaque[TokenUsdPriceTimestamp, Instant]

  opaque type TokenUsdPriceValue = BigDecimal
  object TokenUsdPriceValue extends Opaque[TokenUsdPriceValue, BigDecimal]


  // TokenUsdPriceValue is stored in database as NUMERIC(20, 8)
  given arbTokenUsdPriceValue: Arbitrary[TokenUsdPriceValue] = Arbitrary {
    Gen.chooseNum[Double](0.0001, 20000.0).map { randomDouble =>
      TokenUsdPriceValue(BigDecimal(randomDouble).setScale(8, RoundingMode.UP))
    }
  }


private lazy val tokenUsdPriceGenerator = allGenerators[TokenUsdPrice].normal


val tokenUsdPrice = tokenUsdPriceGenerator.generate // the arbitrary instance in scope is not used by this call
luksow commented

Will be closed in: #397