Closed PWBENNETT closed 2 years ago
Hey 👋
I'm wondering if such option should not come as a satellite package based on fast-check. Having it natively would probably brings some unwanted extra development time to the core and increase the complexity to start with fast-check's core.
But it seems it could fit to the idea of an external package adding some extra arbitraries into fast-check.
By the way, strings will be the main target for v3. Current generators around strings have many important things to do better.
Sorry for the late answer.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
💡 Idea
Generating strings is not just for regexes. The same techniques can be used with any grammar.
Motivation
I came here with a background in using Python's "hypothesis" and Perl's "LectroTest". One of the awesome things in hypothesis is that it can read the same grammar format as the "lark" Earley algorithm parser. Instead of reading text, though, hypothesis runs the rules backwards to generate strings matching any grammar you can think of. Far more than any regex can express, at least.
https://nearley.js.org/ seems to be the "lark" of the JavaScript world, and the good news is that running the rules backwards requires recursive code far less clever than needed fof running them in the usual direction.
Example
I'm not yet familiar enough with the fast-check API to spell out an example word for word, but it looks like the right keywords are "recursive charArb", I think.