typelevel / typelevel/scalacheck
Add edge cases to Gen.choose[BigInt]
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2k
- Forks
- 393
- Avg merge
- 6h 42m
- Merged PRs (30d)
- 4
Description
The following property test should clearly fail:
object ScalaCheckCheck extends Properties("Gen.choose[BigInt]"):
override def overrideParameters( params: Parameters ): Parameters
= params.withMinSuccessfulTests(1_000_000)
property("covers all bit lengths") = forAll(
Gen.choose[BigInt](0, BigInt(1) << 64)
)( _.bitLength > 32 )
end ScalaCheckCheck
But since Gen.choose[BigInt] samples uniformly, the chances of the test above (correctly) failing are less than 3 in 10_000.
The documentation does not mandate that Gen.choose[BigInt] samples uniformly, so I propose adding the following edge cases and sampling methods to Choose[BigInt]:
{0, ±1, ±2, ± Byte.MaxValue ± 1, ± Short.MaxValue ± 1, ...}(provided they are in range)- Randomly chosen small primes or probable primes
- Products of 2 or 3 small/probable primes
- Random Powers of 2
- "Sparse"
BigIntvalues with uniformly random bitLength and uniformly random number of 1-bits
If these additions are acceptable, I would be willing to work on an according PR.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Gen.choose[BigInt] and Choose[BigInt], then reproduce the supplied ScalaCheckCheck property using the stated one-million-test parameter. Review whether the proposed boundary values, primes, products, powers of two, and sparse values should be included, and define the accepted sampling behavior and edge-case coverage before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100