tests/testthat/setup-tests.R

# ERROR FOR NON-SQ OBJECTS ----
test_sq_only <- function(.func, ..., .data.frame_ok = FALSE) {
  test_message <- if (.data.frame_ok)
    "the first argument must be of sq or data.frame class" else
      "the first argument must be of sq class"

  test_that(test_message, {
    expect_s3_class(rlang::catch_cnd(.func(1:7, ...)),
                    "error_no_method")
    expect_s3_class(rlang::catch_cnd(.func(LETTERS, ...)),
                    "error_no_method")
    expect_s3_class(rlang::catch_cnd(.func(list(mean, sum, sd), ...)),
                    "error_no_method")
  })
}

Try the tidysq package in your browser

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

tidysq documentation built on April 12, 2025, 1:37 a.m.