Skip to content

Commit

Permalink
Remove unused testing helper: generate_test_samples()
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed May 15, 2024
1 parent 4f78252 commit 64a422f
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,48 +269,6 @@ n_times_faster_bench <- function(i, x1, x2, fun, ..., n, clear) {
)
}


#' Generate a comprehensive collection test cases for comment / insertion
#' interaction
#' Test consist of if / if-else / if-else-if-else cases, paired with various
#' line-break and comment configurations. Used for internal testing.
#' @return
#' The function is called for its side effects, i.e. to write the
#' test cases to *-in.R files that can be tested with [test_collection()]. Note
#' that a few of the test cases are invalid and need to be removed / commented
#' out manually.
#' @keywords internal
generate_test_samples <- function() {
gen <- function(x) {
if (length(x) == 0L) {
""
} else {
c(
paste0(x[1L], gen(x[-1L])),
paste0(x[1L], " # comment\n", paste(x[-1L], collapse = ""))
)
}
}

collapse <- function(x) paste(x, collapse = "\n\n")

cat(
collapse(gen(c("if", "(", "TRUE", ")", "NULL"))),
file = "tests/testthat/insertion_comment_interaction/just_if-in.R"
)
cat(
collapse(gen(c("if", "(", "TRUE", ")", "NULL", " else", " NULL"))),
file = "tests/testthat/insertion_comment_interaction/if_else-in.R"
)
cat(
collapse(gen(c(
"if", "(", "TRUE", ")", "NULL", " else", " if", "(", "FALSE", ")", "NULL",
" else", " NULL"
))),
file = "tests/testthat/insertion_comment_interaction/if_else_if_else-in.R"
)
}

#' @include ui-caching.R
clear_testthat_cache <- purrr::partial(cache_clear, "testthat", ask = FALSE)
activate_testthat_cache <- purrr::partial(cache_activate, "testthat")
Expand Down

0 comments on commit 64a422f

Please sign in to comment.