Skip to content

Improve QuickCheck shrink candidate ordering - #4149

Open
mizchi wants to merge 2 commits into
moonbitlang:mainfrom
mizchi:optimize-quickcheck-shrink-order
Open

Improve QuickCheck shrink candidate ordering#4149
mizchi wants to merge 2 commits into
moonbitlang:mainfrom
mizchi:optimize-quickcheck-shrink-order

Conversation

@mizchi

@mizchi mizchi commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Reorders built-in QuickCheck shrink candidates from simpler to more complex values.

  • Try zero before nearby numeric values
  • Allow lists to shrink directly to empty
  • Try None before Some candidates
  • Avoid repeated zero candidates when shrinking floating-point values

A regression test with an initial value of 10000 previously exhausted all 100 shrink attempts and stopped at 9900. It now reaches the failure boundary at 5000 in one successful shrink (15 candidates examined).

Validation: moon test --target all, moon check --target all, and moon info.

Copilot AI lite review requested due to automatic review settings August 24, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request reorders QuickCheck shrink candidates to reach simpler counterexamples faster.

Changes:

  • Prioritizes zero, empty collections, and None.
  • Removes duplicate floating-point zero candidates.
  • Updates snapshots and adds regression coverage.

The driver regression test currently reports 27 attempts rather than the documented 15 because a second shrink pass is counted.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
quickcheck/shrink/utils.mbt Filters duplicate floating-point zero candidates.
quickcheck/shrink/shrink.mbt Reorders numeric shrink candidates.
quickcheck/shrink/shrink_test.mbt Updates numeric shrink snapshots.
quickcheck/shrink/composite.mbt Prioritizes None candidates.
quickcheck/shrink/composite_test.mbt Updates composite snapshots.
quickcheck/shrink/collection.mbt Allows lists to shrink directly to empty.
quickcheck/shrink/collection_test.mbt Adds list regression coverage and updates snapshots.
quickcheck/README.mbt.md Updates documented shrink output.
quickcheck/driver_test.mbt Adds numeric shrinking budget regression coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread quickcheck/driver_test.mbt
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

Successfully merging this pull request may close these issues.

2 participants