Repository navigation
Add assert_regex - #43
Conversation
|
I am unsure about potential code sharing with |
|
Pleased add a test for the invalid regex branch. |
c28cb7b to
75c4111
Compare
Test the new `assert_regex` function.
Add a convenient version of `[[ =~ ]]`.
b777b66 to
4f8544b
Compare
|
I added the error case test and fixed a copy-paste issue. I also found that the multi-line value case needs more test coverage and documentation. It's not obvious that the assert succeeds when any line of the |
I would have thought that it is default regex behavior to Match anywhere in the string If there are no begin/end markers ($^). |
c050578 to
ddf9011
Compare
This is the case, but I don't know by heart how multi-line stuff is handled exactly, so I added a couple characterization tests. |
|
73f9021 to
bb7d116
Compare
|
should be good to go now |
| If the value is longer than one line then it is displayed in *multi-line* | ||
| format. | ||
|
|
||
| Multi-line value matches a single-line pattern when one of its lines matches, |
There was a problem hiding this comment.
I find that description a bit confusing. This sounds like matching of multiline strings works per line. The "single line pattern" wording might be misleading, as a pattern might match across linebreaks without containing an obvious \n.
There was a problem hiding this comment.
I get what you mean (\n in the value matches . in the pattern) and I was confused as I don't use multi-line matching often. The message needs an improvement, I agree. I will see how fast I can do it.
There was a problem hiding this comment.
I am planning to simply refer to the Bash docs: https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#:~:text=[[…]], as it's rather complicated. The applied case sensitivity should also be made visible to users, IMHO. BASH_REMATCH visibility should be part of a test, too.
|
Should we also provide refute_regex in this PR? |
I prefer a separate PR, to keep the batch size small and get things done faster. |
Add a copy to the implementation, too.
bb7d116 to
d950f28
Compare
|
Thanks for your contribution. |
Add a function wrapping the commonly used
[[ value =~ pattern ]]construct, printing both operands in case of failure.
This addresses the need in #7 without affecting backward compatibility
of
assert_equal.