tests/testthat/helper-expectations.R

expect_not_identical <- function(
    object,
    expected,
    info = NULL,
    label = NULL,
    expected.label = NULL,
    ...
) {
  act <- quasi_label(rlang::enquo(object), label, arg = 'object')
  exp <- quasi_label(rlang::enquo(expected), expected.label, arg = 'expected')
  comp <- testthat:::waldo_compare(
    x = act$val,
    y = exp$val,
    ...,
    x_arg = 'actual',
    y_arg = 'expected'
  )
  expect(
    ok = length(comp) != 0,
    failure_message = sprintf(
      '%s (`actual`) does not differ from %s (`expected`).\n\n%s',
      act$lab,
      exp$lab,
      paste0(comp, collapse = '\n\n')
    ),
    info = info,
    trace_env = rlang::caller_env()
  )
  invisible(act$val)
}

Try the expstudy package in your browser

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

expstudy documentation built on May 29, 2024, 4:05 a.m.