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

Strategy for ensuring functional correctness? #13

Open
ColinEberhardt opened this issue Jan 25, 2021 · 4 comments
Open

Strategy for ensuring functional correctness? #13

ColinEberhardt opened this issue Jan 25, 2021 · 4 comments
Labels
question Further information is requested

Comments

@ColinEberhardt
Copy link
Owner

I'd consider this library to be a useable POC (proof of concept) in its current state. The implementation is based around the description of regex as provided by the MDN regex cheat sheet, however, this is not a detailed description of the regex language and in some places deviates from others see - #9

At this point it probably makes sense to consider a few points:

  1. What regex specification should this library use for the purposes of implementation?
  2. How should this library be tested in order to meet this specification?
@ColinEberhardt ColinEberhardt added the question Further information is requested label Jan 25, 2021
@ColinEberhardt
Copy link
Owner Author

My initial thoughts

  1. The regular-expressions.info website has very detailed (and easy to understand) descriptions of the syntax and functionality. It also describes languages-specific variations, including JavaScript. See for example the page on char classes
  2. TC39 / Test262 is probably a good test suite - although I'm not sure whether the focus is on the correctness of the RegExp API, or the regular expression language itself.

@dcodeIO
Copy link

dcodeIO commented Jan 25, 2021

As far as I know, and I know little, irregex, an implementation in Scheme, became the benchmark for browser RegExp with both Chrome and Firefox using it nowadays. Some random comments around the web even indicated that it's more standard in practice now than the specification itself, but not sure if that's actually the case. Perhaps a strategy could be to aim at compatibility with what the ES specification defines, and in case of doubt look at what irregex does? Hmm. Regarding testing, this makes me wonder if there may be tests somewhere in Chrome/FF one could run in addition.

@ColinEberhardt
Copy link
Owner Author

Thanks @dcodeIO - I was not aware of iiregex.

@MaxGraey
Copy link
Contributor

Another possible solution could be fuzz testing which generate some valid regexps with different inputs and flags and compare result with the same parameters from JavaScript's RegExp.

Probably this library great starting point: https://github.com/codenote/regex-fuzz/blob/master/main.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants