Closed maelle closed 2 weeks ago
throws_error()
: expect_error()
is_equivalent_to()
: expect_equal(ignore_attr = TRUE)
prints_text
: snapshot or expect_output
is_connected
: use expect_true()
(but never used inside expect_is()
?)is_tree
: use expect_true()
(but never used inside expect_is()
?)gives_warning
: expect_warning()
is_identical_to
: expect_identical()
?parse_script <- function(path) {
cli::cli_alert_info("Reading {path}.")
lines <- brio::read_lines(path)
xml <- path |>
parse(keep.source = TRUE) |>
xmlparsedata::xml_parse_data(pretty = TRUE) |>
xml2::read_xml()
deprecated <- xml2::xml_find_all(
xml,
".//SYMBOL_FUNCTION_CALL[text()='expect_that']"
)
purrr::map(deprecated, treat_deprecated, path = path) |>
unlist() |>
unique()
}
treat_deprecated <- function(xml, path) {
siblings <- xml2::xml_parent(xml) |> xml2::xml_siblings()
xml2::xml_text(siblings[[4]])|>
stringr::str_remove_all("\\(.*")
}
paths <- fs::dir_ls("tests/testthat", regex = "test-")
purrr::map(paths, parse_script) |> unlist() |> unique()
Often they'll be replaceable by
expect_equal()
.