-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
more powerful optional text #150
Comments
Given the effective EBNF from #44: cucumber-expression = (alternation
| optional
| parameter
| text)*
text = (- text-to-escape) | ('\', text-to-escape)
text-to-escape = '(' | '{' | '/' | '\'
alternation = single-alternation, ('/', single_alternation)+
single-alternation = ((text-in-alternative+, optional*)
| (optional+, text-in-alternative+))+
text-in-alternative = (- alternative-to-escape) | ('\', alternative-to-escape)
alternative-to-escape = ' ' | '(' | '{' | '/' | '\'
optional = '(', text-in-optional+, ')'
text-in-optional = (- optional-to-escape) | ('\', optional-to-escape)
optional-to-escape = '(' | ')' | '{' | '/' | '\'
parameter = '{', name*, '}'
name = (- name-to-escape) | ('\', name-to-escape)
name-to-escape = '{' | '}' | '(' | '/' | '\' This would add left-right-space-optional = ' ', '(', text-in-optional+, ')', ' '
left-space-optional = ' ', '(', text-in-optional+, ')'
right-space-optional = '(', text-in-optional+, ')', ' '
optional = '(', text-in-optional+, ')' And the production rules
I don't immediately see any problems with this. Unfortunately the current parser structure does implement this EBNF, but doesn't match its structure so adding it would be a little bit trickier. |
Maybe not:
Would produce
But won't match |
I’m not sure if I understand this. Would then |
Worse, it would match I'm not good at EBNFs, but I think
|
Mmh. But what about this trainwreck
This should match
But that will be tricky because the Or with the first
This should match
But the |
Would then |
No, you're right. I'm being incredibly sloppy.
And then to handle variants like
I think. Doesn't look like a simple change. 😆 |
I guess we could reduce the complexity of this enhancement a lot, if we introduced only I guess the only downside of this simplified approach is that it does not help with braces at the beginning of the cucumber expression. On the other hand, I cannot find a good example where this matters. |
Any hope for this one? 🙏 |
Bit hard to say, I'm trying to get a bit of a workflow setup so I'm not the sole decision maker. Though given that this is a relatively large amount of work (compared to the available time) and given that between duplicating step definitions and/or using regex there are reasonable alternatives if we do think this is a good idea, we might only solicit a pull request. |
Thanks for the reply. I see. I am already using this feature a lot, enabled by my workaround (in TypeScript):
There might be exotic cases where this does not work, though. |
FWIW this makes intuitive sense to me to support it. It's often frustrated me too. I'm not deep enough in the implementation to understand the implied complexity of making it happen (so it's easy for me to say!) though I'd be happy to pair with someone who is and see if I can add anything. |
🤔 What's the problem you're trying to solve?
Currently optional text is only good for a plural s and the like.
So
I have {int} cucumber(s) in my belly
matchesI have 1 cucumber in my belly
.I want to implement even less variants of identical test steps by having a more powerful optional text.
✨ What's your proposed solution?
I should not see the population (anymore)
to matchI should not see the population
.(no extra space at the end of the text)
I should be (back) on the start page
to matchI should be on the start page
.(no double space in the text)
sehe ich (wieder) den/die Breadcrumb(s) {string}
to matchsehe ich den Breadcrumb "Start"
.(still mixable with alternative text)
⛏ Have you considered any alternatives or workarounds?
Ugly workarounds:
I am on the start page
(space at the end)I am on the start page( again)
📚 Any additional context?
To be honest, I am somewhat surprised this doesn't work out of the box. See also the original discussion in another project.
This text was originally generated from a template, then edited by hand. You can modify the template here.
The text was updated successfully, but these errors were encountered: