QuickCheck Mini (WIP) - #3955
Conversation
There was a problem hiding this comment.
Pull request overview
Adds core building blocks for a “QuickCheck Mini (WIP)” in moonbitlang/core, introducing a shrinker API and a size-aware generator API, plus tuple/list instances and corresponding package wiring.
Changes:
- Introduces
@quickcheck/shrinkwith aShrinktrait, primitive/composite shrinkers, and tests. - Adds
@quickcheck/genproviding aGen[T]generator type with common combinators and tests. - Extends tuple/list packages with
Shrinkinstances, updates tupleArbitrarycoverage to 8/9-tuples, and updatesmoon.pkg/ generated.mbtiinterfaces accordingly.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
tuple/tuple_shrink.mbt |
Adds @shrink.Shrink impls for tuples (2–9). |
tuple/tuple_shrink_test.mbt |
Adds snapshot tests validating tuple shrinking behavior. |
tuple/tuple_arbitrary.mbt |
Adds @quickcheck.Arbitrary impls for 8- and 9-tuples. |
tuple/pkg.generated.mbti |
Exposes new tuple Shrink impls and imports quickcheck/shrink. |
tuple/moon.pkg |
Adds moonbitlang/core/quickcheck/shrink dependency. |
tuple/extends.mbt |
Adds deprecated extend entries to avoid promoting Shrink methods as inherent tuple methods. |
quickcheck/shrink/utils.mbt |
Adds shared helpers for shrinkers (array chunk removal + decimal shrinking). |
quickcheck/shrink/shrink.mbt |
Defines Shrink trait plus primitive shrinker impls and docs. |
quickcheck/shrink/shrink_test.mbt |
Adds tests for primitive shrinkers. |
quickcheck/shrink/composite.mbt |
Adds composite shrinkers for Option, Result, Array, and Iter. |
quickcheck/shrink/composite_test.mbt |
Adds tests for composite shrinkers. |
quickcheck/shrink/pkg.generated.mbti |
Generated interface for the new quickcheck/shrink package. |
quickcheck/shrink/moon.pkg |
Declares quickcheck/shrink package imports and warning config. |
quickcheck/gen/gen.mbt |
Implements Gen[T] and generator combinators (map, flat_map, one_of, frequency, etc.). |
quickcheck/gen/gen_test.mbt |
Adds tests for generator behavior and combinators. |
quickcheck/gen/moon.pkg |
Declares quickcheck/gen package imports. |
quickcheck/gen/pkg.generated.mbti |
Generated interface for the new quickcheck/gen package. |
list/shrink.mbt |
Adds @shrink.Shrink impl for List[T]. |
list/pkg.generated.mbti |
Exposes new list Shrink impl and imports quickcheck/shrink. |
list/moon.pkg |
Adds moonbitlang/core/quickcheck/shrink dependency. |
list/list_test.mbt |
Adds snapshot test for list shrinking. |
list/extends.mbt |
Adds deprecated extend entry to avoid promoting Shrink methods as inherent list methods. |
Comments suppressed due to low confidence (2)
list/list_test.mbt:1220
- After fixing list shrinking to include suffix removals, shrinking
[1,2,3,4,5,6]should also include removing the last chunk of size 3 (<List: [1, 2, 3]>).
#| <List: [4, 5, 6]>,
quickcheck/shrink/composite_test.mbt:74
- After fixing array chunk removal to allow suffix removal, shrinking
[1,2,3,4,5,6]should also include removing the last chunk of size 3 ([1, 2, 3]).
#| [0, 2, 3, 4, 5, 6],
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Feedback from migrating a real project to this package: moonbit-community/toml-parser#122 replaced all of its
A patch implementing 1, 2, 4, and 5 is prepared (all 7015 core tests pass with seeded snapshots updated) and will be submitted as a follow-up PR. 🤖 Generated with Claude Code |
Shrinkand instances for common used data types