typelevel / typelevel/scalacheck

Arbitrary, Gen and Choose instances for primitive types should respect size

Open
#448 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2k
Forks
393
Avg merge
6h 42m
Merged PRs (30d)
4

Description

Currently all generators, arbitrary and choose instances for primitives types such as Short, Int, Long, Float, Double and String do not respect the size afaik. Is there a reason for this?

After a quick glance I also have the feeling that the buildable instances (e.g. List, etc) do not respect size either.

If there is no good reason, I think this should be changed. The QuickCheck implementation in Haskell provides a good starting point for properly sized instances of these types. I would certainly appreciate them, because it would allow scaling down numbers and array/list sizes for tests if necessary (e.g. numeric calculations where errors become to big when using huge floats or doubles).

I'd be happy to implement this if it will become incorporated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Arbitrary, Gen, and Choose instances for primitive types and buildable types such as List. Compare their size behavior with the Haskell QuickCheck implementation, then define and test size-respecting behavior for numeric, String, and collection generators.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.