File: test-error.R

package info (click to toggle)
r-cran-tibble 3.0.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,492 kB
  • sloc: ansic: 315; sh: 10; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 917 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
test_that("has_tibble_arg()", {
  # Need to evaluate has_tibble_arg() in the context of an exported function
  # Need to increase the number of frames because running in testthat
  expect_true(tibble(has = has_tibble_arg(".name_repair", n_frames = 60))$has)
  expect_false(tibble(has = has_tibble_arg("dont_have_that_argument", n_frames = 60))$has)
})

test_that("tibble_error()", {
  # Must be called from a function whose name starts with `error_`
  error_foo <- function() {
    tibble_error("message", foo = 42, bar = 7)
  }
  expect_identical(
    error_foo(),
    error_cnd(
      .subclass = c("tibble_error_foo", "tibble_error"),
      message = "message",
      foo = 42,
      bar = 7
    )
  )
})

test_that("output test", {
  expect_snapshot({
    invalid_df("must be integer", "col", "\nFix this.")
    invalid_df("must be numeric", c("col1", "col2"))

    use_repair(TRUE)
    use_repair(FALSE)
  })
})