tests/testthat/test-time_it.R

# time_it -----------------------------------------------------------------
test_that("decorating a function with time_it extends another function abilities", {
    expect_silent(Sys.sleep(0.01))
    expect_type(Sys.sleep <- time_it(base::Sys.sleep), "closure")
    expect_output(Sys.sleep(0.01), "Time difference of")
})

Try the decorators package in your browser

Any scripts or data that you put into this service are public.

decorators documentation built on Sept. 30, 2022, 5:06 p.m.