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

Allow the use of empty look-arounds #18

Open
tom-lord opened this issue Dec 22, 2017 · 0 comments
Open

Allow the use of empty look-arounds #18

tom-lord opened this issue Dec 22, 2017 · 0 comments

Comments

@tom-lord
Copy link
Owner

tom-lord commented Dec 22, 2017

Due to how this library's algorithm works, look-arounds cannot be supported. As explained in the README, a RegexpExamples::IllegalSyntax will be raised if they are used in a pattern you attempt to generate examples for.

However, similar to how the library currently "ignores" \G. ^ and \A anchors at the beginning of a pattern; or $, \z and \Z at the end; it would also be safe to ignore empty look arounds!

For example, the following could be considered safe:

/foo|bar(?=)/.random_example #=> "foo"

One motivation for this stems from the fact that Regexp.union returns an empty look-ahead if no patterns are given:

Regexp.union([]) #=> /(?!)/

Therefore one would expect the following to work as follows, rather than raising an exception:

Regexp.union([]).random_example #=> ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant