tests/testthat/test-on-failure.R

context("on-failure")

test_that("on_failure should work", {
  is_red <- function(x) {x == "red"}
  on_failure(is_red) <- function(call, env) {
      paste0(deparse(call$x), " is not red")
  }
  
  res <- see_if(is_red("blue"))
  expect_false(res[[1]])
  expect_identical(attr(res, "msg"), '"blue" is not red')
})

Try the assertthat package in your browser

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

assertthat documentation built on May 1, 2019, 10:25 p.m.