Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

The fc.statistics function now returns classification data instead of only logging it, enabling programmatic validation of arbitrary distributions.

Changes

  • New StatisticsReport type with classes (label→count map), numRuns, and numSkipped fields
  • Updated statistics function to return StatisticsReport while preserving existing logging behavior
  • Exported type from main package for TypeScript consumers

Usage

// Property test your arbitraries by asserting on distributions
const report = fc.statistics(
  fc.string(),
  (v) => `${v.length} characters`,
  { numRuns: 100_000 }
);

// Assert on coverage
assert(report.classes['1 characters'] > 0);
assert(Object.keys(report.classes).length > 1); // Has variety

// Or use in property tests
fc.assert(fc.property(fc.integer(), (seed) => {
  const results = fc.statistics(
    myCustomArbitrary,
    classifier,
    { numRuns: 1000, seed, logger: () => {} }
  );
  return results.classes['edge_case'] > 0;
}));

The numSkipped field tracks values where the classifier returned an empty array. Multiple classifications per value are supported—numSkipped counts unique values, not total classifications.

Original prompt

fix #4342


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2025

⚠️ No Changeset found

Latest commit: d4c8379

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI changed the title [WIP] Fix issue related to fast-check functionality ✨ Give fc.statistics a return value Dec 22, 2025
Copilot AI requested a review from dubzzz December 22, 2025 14:41
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.

Give fc.statistics a return value

2 participants