Skip to content

Commit

Permalink
πŸ—‘οΈ Deprecate bigInt's alternatives (#5238)
Browse files Browse the repository at this point in the history
**Description**

<!-- Please provide a short description and potentially linked issues
justifying the need for this PR -->

Starting at 3.22.0 the usage of `bigIntN`, `bigUintN` and `bigUint` will
be discouraged. We instead recommend calling `bigInt` with appropriate
`min` and `max` values when relevant.

<!-- * Your PR is fixing a bug or regression? Check for existing issues
related to this bug and link them -->
<!-- * Your PR is adding a new feature? Make sure there is a related
issue or discussion attached to it -->

<!-- You can provide any additional context to help into understanding
what's this PR is attempting to solve: reproduction of a bug, code
snippets... -->

**Checklist** β€” _Don't delete this checklist and make sure you do the
following before opening the PR_

- [x] The name of my PR follows [gitmoji](https://gitmoji.dev/)
specification
- [x] My PR references one of several related issues (if any)
- [x] New features or breaking changes must come with an associated
Issue or Discussion
- [x] My PR does not add any new dependency without an associated Issue
or Discussion
- [x] My PR includes bumps details, please run `yarn bump` and flag the
impacts properly
- [x] My PR adds relevant tests and they would have failed without my PR
(when applicable)

<!-- More about contributing at
https://github.com/dubzzz/fast-check/blob/main/CONTRIBUTING.md -->

**Advanced**

<!-- How to fill the advanced section is detailed below! -->

- [x] Category: πŸ—‘οΈ Depreciate features
- [x] Impacts: Less built-in in future majors

<!-- [Category] Please use one of the categories below, it will help us
into better understanding the urgency of the PR -->
<!-- * ✨ Introduce new features -->
<!-- * πŸ“ Add or update documentation -->
<!-- * βœ… Add or update tests -->
<!-- * πŸ› Fix a bug -->
<!-- * 🏷️ Add or update types -->
<!-- * ⚑️ Improve performance -->
<!-- * _Other(s):_ ... -->

<!-- [Impacts] Please provide a comma separated list of the potential
impacts that might be introduced by this change -->
<!-- * Generated values: Can your change impact any of the existing
generators in terms of generated values, if so which ones? when? -->
<!-- * Shrink values: Can your change impact any of the existing
generators in terms of shrink values, if so which ones? when? -->
<!-- * Performance: Can it require some typings changes on user side?
Please give more details -->
<!-- * Typings: Is there a potential performance impact? In which cases?
-->
  • Loading branch information
dubzzz authored Aug 25, 2024
1 parent bc5005b commit 1baccc5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .yarn/versions/0a0bca50.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
releases:
fast-check: minor

declined:
- "@fast-check/ava"
- "@fast-check/jest"
- "@fast-check/vitest"
- "@fast-check/worker"
1 change: 1 addition & 0 deletions packages/fast-check/src/arbitrary/bigIntN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BigIntArbitrary } from './_internals/BigIntArbitrary';
*
* @param n - Maximal number of bits of the generated bigint
*
* @deprecated Please use ${@link bigInt} with `fc.bigInt({ min: -2n**(n-1n), max: 2n**(n-1n)-1n })` instead
* @remarks Since 1.9.0
* @public
*/
Expand Down
4 changes: 3 additions & 1 deletion packages/fast-check/src/arbitrary/bigUint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function computeDefaultMax(): bigint {

/**
* For positive bigint
* @deprecated Please use ${@link bigInt} with `fc.bigInt({ min: 0n })` instead
* @remarks Since 1.9.0
* @public
*/
Expand All @@ -30,7 +31,7 @@ function bigUint(): Arbitrary<bigint>;
* For positive bigint between 0 (included) and max (included)
*
* @param max - Upper bound for the generated bigint
*
* @deprecated Please use ${@link bigInt} with `fc.bigInt({ min: 0n, max })` instead
* @remarks Since 1.9.0
* @public
*/
Expand All @@ -40,6 +41,7 @@ function bigUint(max: bigint): Arbitrary<bigint>;
*
* @param constraints - Constraints to apply when building instances
*
* @deprecated Please use ${@link bigInt} with `fc.bigInt({ min: 0n, max })` instead
* @remarks Since 2.6.0
* @public
*/
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/src/arbitrary/bigUintN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BigIntArbitrary } from './_internals/BigIntArbitrary';
*
* @param n - Maximal number of bits of the generated bigint
*
* @deprecated Please use ${@link bigInt} with `fc.bigInt({ min: 0n, max: 2n**n-1n })` instead
* @remarks Since 1.9.0
* @public
*/
Expand Down
10 changes: 5 additions & 5 deletions website/docs/core-blocks/arbitraries/primitives/bigint.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Generate any possible `bigint` between <code>-2<sup>n-1</sup></code>(included) a

**Signatures:**

- `fc.bigIntN(n)`
- `fc.bigIntN(n)` β€” _deprecated since v3.22.0, prefer [bigInt](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/bigint/#bigint-1) (more details at [#5238](https://github.com/dubzzz/fast-check/pull/5238))_

**with:**

Expand Down Expand Up @@ -105,7 +105,7 @@ Generate any possible positive `bigint` between <code>0</code>(included) and <co

**Signatures:**

- `fc.bigUintN(n)`
- `fc.bigUintN(n)` β€” _deprecated since v3.22.0, prefer [bigInt](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/bigint/#bigint-1) (more details at [#5238](https://github.com/dubzzz/fast-check/pull/5238))_

**with:**

Expand Down Expand Up @@ -140,9 +140,9 @@ Generate any positive bigint value taken up to upper bound included.

**Signatures:**

- `fc.bigUint()`
- `fc.bigUint({max?})`
- `fc.bigUint(max)`
- `fc.bigUint()` β€” _deprecated since v3.22.0, prefer [bigInt](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/bigint/#bigint-1) (more details at [#5238](https://github.com/dubzzz/fast-check/pull/5238))_
- `fc.bigUint({max?})` β€” _deprecated since v3.22.0, prefer [bigInt](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/bigint/#bigint-1) (more details at [#5238](https://github.com/dubzzz/fast-check/pull/5238))_
- `fc.bigUint(max)` β€” _deprecated since v3.22.0, prefer [bigInt](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/bigint/#bigint-1) (more details at [#5238](https://github.com/dubzzz/fast-check/pull/5238))_

**with:**

Expand Down

0 comments on commit 1baccc5

Please sign in to comment.