@@ -280,6 +280,7 @@ expect_condition_matching <- function(
280280  trace_env  =  caller_env(),
281281  error_call  =  caller_env()
282282) {
283+   check_condition_dots(regexp , ... , error_call  =  error_call )
283284  matcher  <-  cnd_matcher(
284285    base_class ,
285286    class ,
@@ -320,21 +321,14 @@ expect_condition_matching <- function(
320321cnd_matcher  <-  function (
321322  base_class ,
322323  class  =  NULL ,
323-   pattern  =  NULL ,
324+   regexp  =  NULL ,
324325  ... ,
325326  inherit  =  TRUE ,
326327  ignore_deprecation  =  FALSE ,
327328  error_call  =  caller_env()
328329) {
329330  check_string(class , allow_null  =  TRUE , call  =  error_call )
330-   check_string(pattern , allow_null  =  TRUE , allow_na  =  TRUE , call  =  error_call )
331- 
332-   if  (is.null(pattern ) &&  dots_n(... ) >  0 ) {
333-     cli :: cli_abort(
334-       " Can't specify {.arg ...} without {.arg pattern}."  ,
335-       call  =  error_call 
336-     )
337-   }
331+   check_string(regexp , allow_null  =  TRUE , allow_na  =  TRUE , call  =  error_call )
338332
339333  function (cnd ) {
340334    if  (! inherit ) {
@@ -352,12 +346,12 @@ cnd_matcher <- function(
352346      if  (! is.null(class ) &&  ! inherits(x , class )) {
353347        return (FALSE )
354348      }
355-       if  (! is.null(pattern ) &&  ! isNA(pattern )) {
349+       if  (! is.null(regexp ) &&  ! isNA(regexp )) {
356350        withCallingHandlers(
357-           grepl(pattern , conditionMessage(x ), ... ),
351+           grepl(regexp , conditionMessage(x ), ... ),
358352          error  =  function (e ) {
359353            cli :: cli_abort(
360-               " Failed to compare {base_class} to {.arg pattern }."  ,
354+               " Failed to compare {base_class} to {.arg regexp }."  ,
361355              parent  =  e ,
362356              call  =  error_call 
363357            )
@@ -582,3 +576,29 @@ cnd_message <- function(x) {
582576  withr :: local_options(rlang_backtrace_on_error  =  " none"  )
583577  conditionMessage(x )
584578}
579+ 
580+ check_condition_dots  <-  function (
581+   regexp  =  NULL ,
582+   ... ,
583+   error_call  =  caller_env()
584+ ) {
585+   if  (! is.null(regexp ) ||  missing(... )) {
586+     return ()
587+   }
588+ 
589+   dot_names  <-  ... names()
590+   if  (is.null(dot_names )) {
591+     dot_names  <-  rep(" "  , ... length())
592+   }
593+   unnamed  <-  dot_names  ==  " " 
594+   dot_names [unnamed ] <-  paste0(" .."  , seq_along(dot_names )[unnamed ])
595+ 
596+   cli :: cli_abort(
597+     c(
598+       " Can't supply {.arg ...} unless {.arg regexp} is set."  ,
599+       " *"   =  " Unused arguments: {.arg {dot_names}}."  ,
600+       i  =  " Did you mean to use {.arg regexp} so {.arg ...} is passed to {.fn grepl}?" 
601+     ),
602+     call  =  error_call 
603+   )
604+ }
0 commit comments