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

Add java.lang.Integer as Default Arbitrary #615

Open
pete-proton opened this issue Jan 30, 2020 · 1 comment
Open

Add java.lang.Integer as Default Arbitrary #615

pete-proton opened this issue Jan 30, 2020 · 1 comment

Comments

@pete-proton
Copy link

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

@nevillelyh
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants