File: test-on-failure.R

package info (click to toggle)
r-cran-assertthat 0.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 220 kB
  • sloc: sh: 9; makefile: 2
file content (12 lines) | stat: -rw-r--r-- 314 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
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')
})