Skip to content

add $test() method #11

@jmbarbone

Description

@jmbarbone

When condition is created, allow for a test() function to be included.

Users can then do something like:

my_condition <- condition(..., test = function(x, y) x > 1)
my_condition$test(x, y, ...))

Which, when TRUE, will pass ... to $message().

Or something like browser(expr = )a

Replaces

if (test()) {
  cnd(condition(...))
}

... would expr be evaluated in the parent frame?

# test would then be quoted?
my_condition <- condition(..., test = x != y)

foo <- function(x, y) {
  my_condition$test()
}
foo <- function(expr) {
  expr <- substitute(expr)
  function() list(foo = eval(expr, parent.frame(1)))
}

bar <- foo(x > 1)

fizz <- function(x) {
  bar()
} 

fizz(1)
#> $foo
#> [1] FALSE
fizz(2)
#> $foo
#> [1] TRUE

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions