Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pk044 opened this issue Sep 1, 2023 · 0 comments
Labels

Comments

@pk044
Copy link
Collaborator

pk044 commented Sep 1, 2023

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
@pk044 pk044 added the bug label Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant