Closed BartJanvanRossum closed 3 years ago
Well, the bracket is a special character in regular expressions, so you need to escape it if you want to match it. Having said that, I think I should add the ...
argument to pass optional arguments like fixed=TRUE
to grepl
.
I assumed it had something to do with this. Indeed the possibility to pass optional arguments to grepl would be nice.
For me what was most annoying that I had a real life case resembling foobar above. That fails, but it is not clear at first sight why
Consider the three example below. Although they appear similar, the behavior of tinytest for the three of them is different.
The test for foo gives this error message: Error in grepl(pattern, e$message) : invalid regular expression '(', reason 'Missing ')'' In addition: Warning message: In grepl(pattern, e$message) : TRE pattern compilation error 'Missing ')''
The test for bar is working fine. The test for foobar however, doesn't give an error message, but the check itself fails with this cryptic message: _----- FAILED[xcpt]: <--> call| expecterror(foobar(), "foobar (fb)") diff| The error message: diff| 'foobar (fb)' diff| does not match pattern 'foobar (fb)'
Especially this last one is worrying since it seems to state that two identical strings are actually different.
Not sure if it is relevant, but I'm using the latest CRAN version of tinytest (1.2.4) and R.4.1.0, though the issue was present in earlier versions of R as well.