tests/tinytest.R

if ( requireNamespace("tinytest", quietly=TRUE) ){
  
  expect_lt <- function(a,b) {
    
    tinytest::tinytest(
      result = a < b,
      call   = sys.call(sys.parent(1)),
      diff   = paste("b - a = ", b - a)
    )
    
  }
  
  expect_output <- function(x, pattern) {
    
    ans  <- paste(capture.output(eval(x)), collapse = "\n")
    test <- grepl(pattern, ans)
    
    tinytest::tinytest(
      result = test,
      call   = sys.call(sys.parent(1)),
      diff   = paste("Expected:", pattern, ". Returned:", ans)
    )
  }
  
  tinytest::test_package("fmcmc")
}

Try the fmcmc package in your browser

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

fmcmc documentation built on Aug. 30, 2023, 1:09 a.m.