Skip to content
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

✨ Support for grapheme on fc.string #5222

Merged
merged 26 commits into from
Aug 22, 2024
Merged

✨ Support for grapheme on fc.string #5222

merged 26 commits into from
Aug 22, 2024

Conversation

dubzzz
Copy link
Owner

@dubzzz dubzzz commented Aug 18, 2024

Description

Strings are everywhere in programming, they have always been and will always be. They are our way to communicate with users in both ways: from them and to them. As such they are a key foundation for any piece of code.

Unfortunately strings are hard. When leaving the peaceful (biased) world of latin characters (ascii) we reach quickly a hard to grab new world. But we have to deal with it, strings are key for any program! As such fast-check wants to guide you through the subtle issues hat might come with strings by providing you with a comprehensive and efficient set of tools for them.

For instance: As a user you may have used Twitter/X. If so you probably heard of the 140-character limit (now bumped to 280 for European characters and still limited to 140 for CJK and Emojis). Actually by 140 they don't mean tweet.length === 140 (counting chars), nor [...tweet].length === 140 (counting code-points), they mean 140 visual signs. And unfortunately it's most of the time what our users expect.

This PR introduces an extra constraint called unit on fc.string. This constraint could be filled with one our 5 presets. Among these presets 'grapheme' is planned to be the new default for version 4 and will behave as users may expect: it counts visual entities, neither chars, nor code-points. In order to help users finding their ideal granularity, we added other grapheme granularities: one for code-points (grapheme-composite) and one for chars (grapheme-ascii). The binary variants are supposed to be replacements for fullUnicode and other custom string versions we offered up to version 3 and that we plan to drop with v4.

See #5221

ChecklistDon't delete this checklist and make sure you do the following before opening the PR

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

Advanced

  • Category: ✨ Introduce new features
  • Impacts: No impact, we enriched fc.string and provided it with new capabilities

@dubzzz dubzzz added the 🧪 Experiment Performing some experiments for potential future features implying deep changes label Aug 18, 2024
Copy link

codesandbox-ci bot commented Aug 18, 2024

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 ce08d15:

Sandbox Source
@fast-check/examples Configuration

Copy link
Contributor

👋 A preview of the new documentation is available at: http://66c1abb39cb5a37554653c80--dubzzz-fast-check.netlify.app

Copy link

codecov bot commented Aug 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.32%. Comparing base (ef7bec9) to head (ce08d15).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5222      +/-   ##
==========================================
+ Coverage   94.73%   95.32%   +0.59%     
==========================================
  Files         231      234       +3     
  Lines        9320    10414    +1094     
  Branches     2731     2774      +43     
==========================================
+ Hits         8829     9927    +1098     
+ Misses        491      487       -4     
Flag Coverage Δ
unit-tests 95.32% <100.00%> (+0.59%) ⬆️
unit-tests-18.x-Linux 95.32% <100.00%> (+0.59%) ⬆️
unit-tests-20.x-Linux 95.32% <100.00%> (+0.59%) ⬆️
unit-tests-22.x-Linux 95.32% <100.00%> (+0.59%) ⬆️
unit-tests-latest-Linux 95.32% <100.00%> (+0.59%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

👋 A preview of the new documentation is available at: http://66c446c6baf803d244ef3281--dubzzz-fast-check.netlify.app

Copy link
Contributor

👋 A preview of the new documentation is available at: http://66c50df659c46d5e56b26357--dubzzz-fast-check.netlify.app

Copy link
Contributor

👋 A preview of the new documentation is available at: http://66c511c599164e5b8a72a4cd--dubzzz-fast-check.netlify.app

Copy link
Contributor

👋 A preview of the new documentation is available at: http://66c5155099164e603c72a71f--dubzzz-fast-check.netlify.app

Copy link
Contributor

👋 A preview of the new documentation is available at: http://66c59b4d08eb95fa86d8611d--dubzzz-fast-check.netlify.app

@dubzzz dubzzz changed the title First drafty grapheme support ✨ Support for grapheme on fc.string Aug 22, 2024
@dubzzz dubzzz removed the 🧪 Experiment Performing some experiments for potential future features implying deep changes label Aug 22, 2024
@dubzzz dubzzz enabled auto-merge (squash) August 22, 2024 07:43
Copy link
Contributor

👋 A preview of the new documentation is available at: http://66c6ecd471a60c8be0cf3877--dubzzz-fast-check.netlify.app

@dubzzz dubzzz merged commit 9f5ec86 into main Aug 22, 2024
58 checks passed
@dubzzz dubzzz deleted the grapheme branch August 22, 2024 07:51
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.

1 participant