Skip to content

Commit

Permalink
💥 Drop deprecated ascii* (#5636)
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 -->

The arbitraries `ascii` and `asciiString` have been marked for
deprecation since version 3.22.0.

They are now being fully dropped.

If you still want to rely on something behaving this way we recommend
you to use the following constructs:

```js
// for asciiString
string({ unit: 'binary-ascii' })

// for ascii
string({ unit: 'binary-ascii', minLength: 1, maxLength: 1 })
```

<!-- * 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: Dropped arbitraries
  • Loading branch information
dubzzz authored Jan 22, 2025
1 parent 00c23e5 commit 2435058
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 292 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-bikes-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fast-check": major
---

💥 Drop deprecated `ascii*` (#5280)
13 changes: 0 additions & 13 deletions packages/fast-check/src/arbitrary/ascii.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/fast-check/src/arbitrary/asciiString.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/fast-check/src/fast-check-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { bigUintN } from './arbitrary/bigUintN';
import { boolean } from './arbitrary/boolean';
import type { FalsyContraints, FalsyValue } from './arbitrary/falsy';
import { falsy } from './arbitrary/falsy';
import { ascii } from './arbitrary/ascii';
import { base64 } from './arbitrary/base64';
import { char } from './arbitrary/char';
import { char16bits } from './arbitrary/char16bits';
Expand Down Expand Up @@ -107,7 +106,6 @@ import type {
} from './arbitrary/uniqueArray';
import { uniqueArray } from './arbitrary/uniqueArray';
import { infiniteStream } from './arbitrary/infiniteStream';
import { asciiString } from './arbitrary/asciiString';
import { base64String } from './arbitrary/base64String';
import { fullUnicodeString } from './arbitrary/fullUnicodeString';
import { hexaString } from './arbitrary/hexaString';
Expand Down Expand Up @@ -361,15 +359,13 @@ export {
bigInt,
bigUint,
char,
ascii,
char16bits,
unicode,
fullUnicode,
hexa,
base64,
mixedCase,
string,
asciiString,
string16bits,
stringOf,
unicodeString,
Expand Down
3 changes: 0 additions & 3 deletions packages/fast-check/test/e2e/GenerateAllValues.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ describe(`Generate all values (seed: ${seed})`, () => {
describe('fc.char()', () => {
it('Should be able to produce any printable character', () => lookForMissing(fc.char(), 95));
});
describe('fc.ascii()', () => {
it('Should be able to produce any character from ascii', () => lookForMissing(fc.ascii(), 128));
});
describe('fc.char16bits()', () => {
it('Should be able to produce any 16 bits character', () => lookForMissing(fc.char16bits(), 65536));
});
Expand Down
10 changes: 0 additions & 10 deletions packages/fast-check/test/e2e/NoRegression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,6 @@ describe(`NoRegression`, () => {
),
).toThrowErrorMatchingSnapshot();
});
it('asciiString', () => {
expect(
runWithSanitizedStack(() =>
fc.assert(
fc.property(fc.asciiString(), (v) => testFunc(v)),
settings,
),
),
).toThrowErrorMatchingSnapshot();
});
// // Jest Snapshot seems not to support incomplete surrogate pair correctly
// it('string16bits', () => {
// expect(runWithSanitizedStack(() => fc.assert(fc.property(fc.string16bits(), v => testFunc(v + v)), settings))).toThrowErrorMatchingSnapshot();
Expand Down
2 changes: 0 additions & 2 deletions packages/fast-check/test/e2e/Poisoning.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ describe(`Poisoning (seed: ${seed})`, () => {
{ name: 'hexa', arbitraryBuilder: () => fc.hexa() },
{ name: 'base64', arbitraryBuilder: () => fc.base64() },
{ name: 'char', arbitraryBuilder: () => fc.char() },
{ name: 'ascii', arbitraryBuilder: () => fc.ascii() },
{ name: 'unicode', arbitraryBuilder: () => fc.unicode() },
{ name: 'char16bits', arbitraryBuilder: () => fc.char16bits() },
{ name: 'fullUnicode', arbitraryBuilder: () => fc.fullUnicode() },
// : Multiple characters
{ name: 'hexaString', arbitraryBuilder: () => fc.hexaString() },
{ name: 'base64String', arbitraryBuilder: () => fc.base64String() },
{ name: 'string', arbitraryBuilder: () => fc.string() },
{ name: 'asciiString', arbitraryBuilder: () => fc.asciiString() },
{ name: 'unicodeString', arbitraryBuilder: () => fc.unicodeString() },
{ name: 'string16bits', arbitraryBuilder: () => fc.string16bits() },
{ name: 'fullUnicodeString', arbitraryBuilder: () => fc.fullUnicodeString() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1473,37 +1473,6 @@ Execution summary:
. . . . . . . . . . . . . . . . . . . √ [[53219898]]]
`;

exports[`NoRegression > asciiString 1`] = `
[Error: Property failed after 2 tests
{ seed: 42, path: "1:1:1:4:1:1:1:2", endOnFailure: true }
Counterexample: ["\\u0000"]
Shrunk 7 time(s)

Execution summary:
√ [""]
× ["zWiHt\\u001d(t"]
. √ [""]
. × ["t\\u001d(t"]
. . √ ["(t"]
. . × ["\\u001d(t"]
. . . √ ["(t"]
. . . √ [" (t"]
. . . √ ["^(t"]
. . . √ ["}(t"]
. . . × ["\\u000e(t"]
. . . . √ ["(t"]
. . . . × ["\\u0006(t"]
. . . . . √ ["(t"]
. . . . . × ["\\u0002(t"]
. . . . . . √ ["(t"]
. . . . . . × ["\\u0000(t"]
. . . . . . . √ ["(t"]
. . . . . . . √ ["~(t"]
. . . . . . . × ["\\u0000"]
. . . . . . . . √ [""]
. . . . . . . . √ ["~"]]
`;

exports[`NoRegression > base64String 1`] = `
[Error: Property failed after 3 tests
{ seed: 42, path: "2:3:5:5", endOnFailure: true }
Expand Down
94 changes: 0 additions & 94 deletions packages/fast-check/test/unit/arbitrary/ascii.spec.ts

This file was deleted.

51 changes: 0 additions & 51 deletions packages/fast-check/test/unit/arbitrary/asciiString.spec.ts

This file was deleted.

18 changes: 0 additions & 18 deletions website/docs/core-blocks/arbitraries/primitives/char.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,6 @@ fc.char();
Resources: [API reference](https://fast-check.dev/api-reference/functions/char.html).
Available since 0.0.1.

## ascii

One ascii character — _ie.: one character between `0x00` (included) and `0x7f` (included)_.

**Signatures:**

- `fc.ascii()`_deprecated since v3.22.0, prefer [string](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/string/#string-1) (more details at [#5233](https://github.com/dubzzz/fast-check/pull/5233))_

**Usages:**

```js
fc.ascii();
// Examples of generated values: "4", "l", "S", ";", "\u0019"…
```

Resources: [API reference](https://fast-check.dev/api-reference/functions/ascii.html).
Available since 0.0.1.

## unicode

One unicode character from BMP-plan — _ie.: one character between `0x0000` (included) and `0xffff` (included) but excluding surrogate pairs (between `0xd800` and `0xdfff`)_.
Expand Down
37 changes: 0 additions & 37 deletions website/docs/core-blocks/arbitraries/primitives/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,43 +117,6 @@ fc.string({ unit: fc.constantFrom('Hello', 'World') });
Resources: [API reference](https://fast-check.dev/api-reference/functions/string.html).
Available since 0.0.1.

## asciiString

ASCII string containing characters produced by `fc.ascii()`.

**Signatures:**

- `fc.asciiString()`_deprecated since v3.22.0, prefer [string](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/string/#string-1) (more details at [#5233](https://github.com/dubzzz/fast-check/pull/5233))_
- `fc.asciiString({minLength?, maxLength?, size?})`_deprecated since v3.22.0, prefer [string](https://fast-check.dev/docs/core-blocks/arbitraries/primitives/string/#string-1) (more details at [#5233](https://github.com/dubzzz/fast-check/pull/5233))_

**with:**

- `minLength?` — default: `0`_minimal number of characters (included)_
- `maxLength?` — default: `0x7fffffff` [more](/docs/configuration/larger-entries-by-default/#size-explained)_maximal number of characters (included)_
- `size?` — default: `undefined` [more](/docs/configuration/larger-entries-by-default/#size-explained)_how large should the generated values be?_

**Usages:**

```js
fc.asciiString();
// Examples of generated values: "\f@D", "hp", "q#dO~?@", "Qad", "5eHqc"…

fc.asciiString({ maxLength: 3 });
// Note: Any ascii string containing up to 3 (included) characters
// Examples of generated values: "6", "", "ty", ",", "k"…

fc.asciiString({ minLength: 3 });
// Note: Any ascii string containing at least 3 (included) characters
// Examples of generated values: "603e", "6W\u001b^tR-\n\n|", "efproto_\u001abhasOw", "$\u001c&\u0000R", "apply"…

fc.asciiString({ minLength: 4, maxLength: 6 });
// Note: Any ascii string containing between 4 (included) and 6 (included) characters
// Examples of generated values: "<&\u001e\u001b ", "bind", "dnGn\\2", "& % !", "__defi"…
```

Resources: [API reference](https://fast-check.dev/api-reference/functions/asciiString.html).
Available since 0.0.1.

## unicodeString

Unicode string containing characters produced by `fc.unicode()`.
Expand Down
Loading

0 comments on commit 2435058

Please sign in to comment.