-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💥 Drop deprecated unicode*
#5315
Conversation
The arbitraries `unicode` and `unicodeString` 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: ```ts const gapSize = 0xdfff + 1 - 0xd800; function unicodeMapper(v: number) { if (v < 0xd800) return v; return v + gapSize; } function unicodeUnmapper(v: number) { if (v < 0xd800) return v; if (v <= 0xdfff) return -1; return v - gapSize; } function unicode(): Arbitrary<string> { return integer({min :0, max: 0xffff - gapSize}).map( v => String.fromCodePoint(unicodeMapper(v)), s => { if (typeof s !== 'string') throw new Error('Invalid'); if (s.length !== 1) throw new Error('Invalid'); return unicodeUnmapper(s.codePointAt(0)) } ); } const unicodeString = (constraints) => fc.string({ ...constraints, unit: unicode() }); ``` We recommend checking for the `unit` constraint offered built-in on `string` arbitraries rather than going for a fully aligned custom `unicode`. Most of the time, if you wanted unicode characters you probably wanted either `grapheme` or `binary`.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 48ed1ba:
|
👋 A preview of the new documentation is available at: http://6702ba35b153107c693f5dbe--dubzzz-fast-check.netlify.app |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next-3_22_0 #5315 +/- ##
===============================================
- Coverage 95.02% 94.90% -0.12%
===============================================
Files 219 217 -2
Lines 10030 9999 -31
Branches 2629 2617 -12
===============================================
- Hits 9531 9490 -41
- Misses 499 509 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Description
The arbitraries
unicode
andunicodeString
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:
We recommend checking for the
unit
constraint offered built-in onstring
arbitraries rather than going for a fully aligned customunicode
. Most of the time, if you wanted unicode characters you probably wanted eithergrapheme
orbinary
.Checklist — Don't delete this checklist and make sure you do the following before opening the PR
yarn bump
and flag the impacts properlyAdvanced