You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is quite neat and useful to be able to create custom matchers, but it is a bit unfortunate that it's not easy/possible to access the actual matcher instance in the RETURN or LR_RETURN statement.
Say you have a custom matcher that matches the regex "I want (\d+) apples", it would be quite useful to be able to access the captured integer easily in the RETURN statement and return something like "Here are " + std::to_string(matcher_object.count()) + " apples".
Currently it seems like the RETURN statement can only access the entire matched input argument(s) (ie. _1, _2 etc.) and in cases like this has to more or less redo the work the matcher has already done.
I might be missing something and I don't know if it makes any sense at all, just thought I would share my thoughts.
The text was updated successfully, but these errors were encountered:
This is an interesting idea that I have not thought of. As it is currently written it is not possible, but it may be achievable. I'll see what I can do, but to be honest, it is unlikely to happen soon.
I wish I could offer the help, but I must admit that the template and macro magic inside trompeloeil is not exactly easy to understand and I assume this requires messing quite a bit with the inner workings of the library.
But let me know if there might be anything I could do to help anyway.
It is quite neat and useful to be able to create custom matchers, but it is a bit unfortunate that it's not easy/possible to access the actual matcher instance in the RETURN or LR_RETURN statement.
Say you have a custom matcher that matches the regex
"I want (\d+) apples"
, it would be quite useful to be able to access the captured integer easily in the RETURN statement and return something like"Here are " + std::to_string(matcher_object.count()) + " apples"
.Currently it seems like the RETURN statement can only access the entire matched input argument(s) (ie.
_1
,_2
etc.) and in cases like this has to more or less redo the work the matcher has already done.I might be missing something and I don't know if it makes any sense at all, just thought I would share my thoughts.
The text was updated successfully, but these errors were encountered: