scalacheck
scalacheck copied to clipboard
Add java.lang.Integer as Default Arbitrary
I need to use java.lang.integer, as explained here & was advised by @DanielaSfregola to bring the issue up here.
Now I do it myself
lazy val jIntGen = Arbitrary.arbitrary[Int].map(_.asInstanceOf[Integer])
but I wonder if it is a biggie to add that to the set of default arbitraries, so to speak. it does not look so bad here, but with nested objects it kind of gets messy.
I guess, it is logical to add other java wrappers like java.lang.Double, lava.lang.Long and etc. if this request makes sense. If it does, I can try to raise a PR myself.
thank you in advance for reviewing the request, Petr
Stumbled upon this one. Note that Java boxed primitives can be null
though, so you might want Arbitrary.arbitrary[Option[Int]].map(_.map(_.asInstanceOf[Integer].getOrElse(null)))
to cover that edge case.