Skip to content

Commit 2c2be12

Browse files
authored
💥 Drop deprecated big{U|}int{N|} (#5345)
**Description** <!-- Please provide a short description and potentially linked issues justifying the need for this PR --> As planned in v3, we are dropping `bigUint`, `bigUintN` and `bigIntN` in favor of `bigInt`. <!-- * 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: 💥 Breaking Change - [x] Impacts: As planned <!-- [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? -->
1 parent 10197a4 commit 2c2be12

18 files changed

+53
-466
lines changed

packages/fast-check/src/arbitrary/_internals/MixedCaseArbitrary.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Random } from '../../random/generator/Random';
22
import type { Stream } from '../../stream/Stream';
3-
import { bigUintN } from '../bigUintN';
3+
import { bigInt } from '../bigInt';
44
import { Arbitrary } from '../../check/arbitrary/definition/Arbitrary';
55
import { Value } from '../../check/arbitrary/definition/Value';
66
import { makeLazy } from '../../stream/LazyIterableIterator';
@@ -51,7 +51,7 @@ export class MixedCaseArbitrary extends Arbitrary<string> {
5151
const chars = [...rawStringValue.value]; // split into valid unicode (keeps surrogate pairs)
5252
const togglePositions = computeTogglePositions(chars, this.toggleCase);
5353

54-
const flagsArb = bigUintN(togglePositions.length);
54+
const flagsArb = bigInt(BigInt(0), (BigInt(1) << BigInt(togglePositions.length)) - BigInt(1));
5555
const flagsValue = flagsArb.generate(mrng, undefined); // true => toggle the char, false => keep it as-is
5656

5757
applyFlagsOnChars(chars, flagsValue.value, togglePositions, this.toggleCase);
@@ -114,7 +114,7 @@ export class MixedCaseArbitrary extends Arbitrary<string> {
114114
makeLazy(() => {
115115
const chars = [...rawString];
116116
const togglePositions = computeTogglePositions(chars, this.toggleCase);
117-
return bigUintN(togglePositions.length)
117+
return bigInt(BigInt(0), (BigInt(1) << BigInt(togglePositions.length)) - BigInt(1))
118118
.shrink(flags, contextSafe.flagsContext)
119119
.map((nFlagsValue) => {
120120
const nChars = safeSlice(chars); // cloning chars

packages/fast-check/src/arbitrary/bigIntN.ts

-23
This file was deleted.

packages/fast-check/src/arbitrary/bigUint.ts

-57
This file was deleted.

packages/fast-check/src/arbitrary/bigUintN.ts

-23
This file was deleted.

packages/fast-check/src/fast-check-default.ts

-8
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ import type { ArrayConstraints } from './arbitrary/array';
2626
import { array } from './arbitrary/array';
2727
import type { BigIntConstraints } from './arbitrary/bigInt';
2828
import { bigInt } from './arbitrary/bigInt';
29-
import { bigIntN } from './arbitrary/bigIntN';
30-
import type { BigUintConstraints } from './arbitrary/bigUint';
31-
import { bigUint } from './arbitrary/bigUint';
32-
import { bigUintN } from './arbitrary/bigUintN';
3329
import { boolean } from './arbitrary/boolean';
3430
import type { FalsyContraints, FalsyValue } from './arbitrary/falsy';
3531
import { falsy } from './arbitrary/falsy';
@@ -251,7 +247,6 @@ export type {
251247
ArrayConstraints,
252248
BigIntConstraints,
253249
BigIntArrayConstraints,
254-
BigUintConstraints,
255250
CommandsContraints,
256251
DateConstraints,
257252
DictionaryConstraints,
@@ -343,10 +338,7 @@ export {
343338
nat,
344339
maxSafeInteger,
345340
maxSafeNat,
346-
bigIntN,
347-
bigUintN,
348341
bigInt,
349-
bigUint,
350342
mixedCase,
351343
string,
352344
base64String,

packages/fast-check/test/e2e/NoRegression.spec.ts

-40
Original file line numberDiff line numberDiff line change
@@ -831,26 +831,6 @@ describe(`NoRegression`, () => {
831831
),
832832
).toThrowErrorMatchingSnapshot();
833833
});
834-
it('bigIntN', () => {
835-
expect(
836-
runWithSanitizedStack(() =>
837-
fc.assert(
838-
fc.property(fc.bigIntN(100), (v) => testFunc(v)),
839-
settings,
840-
),
841-
),
842-
).toThrowErrorMatchingSnapshot();
843-
});
844-
it('bigUintN', () => {
845-
expect(
846-
runWithSanitizedStack(() =>
847-
fc.assert(
848-
fc.property(fc.bigUintN(100), (v) => testFunc(v)),
849-
settings,
850-
),
851-
),
852-
).toThrowErrorMatchingSnapshot();
853-
});
854834
it('bigInt', () => {
855835
expect(
856836
runWithSanitizedStack(() =>
@@ -891,26 +871,6 @@ describe(`NoRegression`, () => {
891871
),
892872
).toThrowErrorMatchingSnapshot();
893873
});
894-
it('bigUint', () => {
895-
expect(
896-
runWithSanitizedStack(() =>
897-
fc.assert(
898-
fc.property(fc.bigUint(), (v) => testFunc(v)),
899-
settings,
900-
),
901-
),
902-
).toThrowErrorMatchingSnapshot();
903-
});
904-
it('bigUint({max})', () => {
905-
expect(
906-
runWithSanitizedStack(() =>
907-
fc.assert(
908-
fc.property(fc.bigUint({ max: BigInt(1) << BigInt(96) }), (v) => testFunc(v)),
909-
settings,
910-
),
911-
),
912-
).toThrowErrorMatchingSnapshot();
913-
});
914874
it('bigInt64Array', () => {
915875
expect(
916876
runWithSanitizedStack(() =>

packages/fast-check/test/e2e/Poisoning.spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ describe(`Poisoning (seed: ${seed})`, () => {
3434
{ name: 'maxSafeNat', arbitraryBuilder: () => fc.maxSafeNat() },
3535
{ name: 'float', arbitraryBuilder: () => fc.float() },
3636
{ name: 'double', arbitraryBuilder: () => fc.double() },
37-
{ name: 'bigIntN', arbitraryBuilder: () => fc.bigIntN(64) },
3837
{ name: 'bigInt', arbitraryBuilder: () => fc.bigInt() },
39-
{ name: 'bigUintN', arbitraryBuilder: () => fc.bigUintN(64) },
40-
{ name: 'bigUint', arbitraryBuilder: () => fc.bigUint() },
4138
// String
4239
// : Multiple characters
4340
{ name: 'base64String', arbitraryBuilder: () => fc.base64String() },

packages/fast-check/test/e2e/arbitraries/ArrayArbitrary.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe(`ArrayArbitrary (seed: ${seed})`, () => {
3030
expect(out.counterexample).toEqual([[5, 5]]);
3131
});
3232
biasIts('integer', fc.integer());
33-
biasIts('bigint', fc.bigIntN(64));
33+
biasIts('bigint', fc.bigInt());
3434
});
3535
});
3636

packages/fast-check/test/e2e/arbitraries/BigIntArbitrary.spec.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ import { seed } from '../seed';
44

55
declare function BigInt(n: number | bigint | string): bigint;
66

7+
function bigInt1030() {
8+
const n = 1030;
9+
const min = BigInt(-1) << BigInt(n - 1);
10+
const max = (BigInt(1) << BigInt(n - 1)) - BigInt(1);
11+
return fc.bigInt({ min, max });
12+
}
13+
714
describe(`BigIntArbitrary (seed: ${seed})`, () => {
815
describe('bitIntN', () => {
916
it('Should be able to generate bigint above the highest positive double', () => {
1017
const out = fc.check(
11-
fc.property(fc.bigIntN(1030), (v) => Number(v) !== Number.POSITIVE_INFINITY),
18+
fc.property(bigInt1030(), (v) => Number(v) !== Number.POSITIVE_INFINITY),
1219
{ seed: seed },
1320
);
1421
expect(out.failed).toBe(true);
@@ -19,7 +26,7 @@ describe(`BigIntArbitrary (seed: ${seed})`, () => {
1926
});
2027
it('Should be able to generate bigint below the smallest negative double', () => {
2128
const out = fc.check(
22-
fc.property(fc.bigIntN(1030), (v) => Number(v) !== Number.NEGATIVE_INFINITY),
29+
fc.property(bigInt1030(), (v) => Number(v) !== Number.NEGATIVE_INFINITY),
2330
{ seed: seed },
2431
);
2532
expect(out.failed).toBe(true);
@@ -30,10 +37,7 @@ describe(`BigIntArbitrary (seed: ${seed})`, () => {
3037
});
3138
it('Should be able to generate small bigint (relatively to maximal bigint asked)', () => {
3239
const out = fc.check(
33-
fc.property(
34-
fc.bigIntN(1030),
35-
(v) => Number(v) < Number.MIN_SAFE_INTEGER || Number(v) > Number.MAX_SAFE_INTEGER,
36-
),
40+
fc.property(bigInt1030(), (v) => Number(v) < Number.MIN_SAFE_INTEGER || Number(v) > Number.MAX_SAFE_INTEGER),
3741
{ seed: seed },
3842
);
3943
expect(out.failed).toBe(true);
@@ -46,7 +50,7 @@ describe(`BigIntArbitrary (seed: ${seed})`, () => {
4650
it('Should be able to generate close to min or max bigints (relatively to the asked range)', () => {
4751
const out = fc.check(
4852
fc.property(
49-
fc.bigIntN(1030),
53+
bigInt1030(),
5054
(v) =>
5155
v >= (BigInt(-1) << BigInt(1030 - 1)) + BigInt(500) && v <= (BigInt(1) << BigInt(1030 - 1)) - BigInt(500),
5256
),
@@ -61,7 +65,7 @@ describe(`BigIntArbitrary (seed: ${seed})`, () => {
6165
it('Should not be able to generate small bigint if not biased (very improbable)', () => {
6266
const out = fc.check(
6367
fc.property(
64-
fc.noBias(fc.bigIntN(1030)),
68+
fc.noBias(bigInt1030()),
6569
(v) => Number(v) < Number.MIN_SAFE_INTEGER || Number(v) > Number.MAX_SAFE_INTEGER,
6670
),
6771
{ seed: seed },
@@ -71,7 +75,7 @@ describe(`BigIntArbitrary (seed: ${seed})`, () => {
7175
it('Should not be able to generate close to min or max bigints if not biased (very improbable)', () => {
7276
const out = fc.check(
7377
fc.property(
74-
fc.noBias(fc.bigIntN(1030)),
78+
fc.noBias(bigInt1030()),
7579
(v) =>
7680
v >= (BigInt(-1) << BigInt(1030 - 1)) + BigInt(500) && v <= (BigInt(1) << BigInt(1030 - 1)) - BigInt(500),
7781
),

packages/fast-check/test/unit/arbitrary/_internals/BigIntArbitrary.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ describe('BigIntArbitrary (integration)', () => {
246246
fc.assert(
247247
fc.property(
248248
fc.bigInt(),
249-
fc.bigUint({ max: BigInt(20) }), // larger trees might be too wide
250-
fc.bigUint({ max: BigInt(20) }),
249+
fc.bigInt({ min: BigInt(0), max: BigInt(20) }), // larger trees might be too wide
250+
fc.bigInt({ min: BigInt(0), max: BigInt(20) }),
251251
(start, o1, o2) => {
252252
// Arrange
253253
const min = start;
@@ -276,10 +276,10 @@ describe('BigIntArbitrary (integration)', () => {
276276
it('should build an offset version of the shrinking tree if we offset all the values (keep every value >=0)', () =>
277277
fc.assert(
278278
fc.property(
279-
fc.bigUint(),
280-
fc.bigUint({ max: BigInt(20) }), // larger trees might be too wide
281-
fc.bigUint({ max: BigInt(20) }),
282-
fc.bigUint(),
279+
fc.bigInt({ min: BigInt(0) }),
280+
fc.bigInt({ min: BigInt(0), max: BigInt(20) }), // larger trees might be too wide
281+
fc.bigInt({ min: BigInt(0), max: BigInt(20) }),
282+
fc.bigInt({ min: BigInt(0) }),
283283
(start, o1, o2, offset) => {
284284
// Arrange
285285
fc.pre(start + o1 + offset <= Number.MAX_SAFE_INTEGER);

0 commit comments

Comments
 (0)