f <- function() TRUE
g <- function() f()
stub(g, 'f', FALSE)
# now g() returns FALSE because f() has been stubbed out
g()
# you can stub multiple functions by calling stub() multiple times
f <- function() TRUE
g <- function() TRUE
h <- function() any(f(), g())
stub(h, 'f', FALSE)
stub(h, 'g', FALSE)
# now h() returns FALSE because both f() and g() have been stubbed out
h()
Run the code above in your browser using DataLab