Skip to content

Commit

Permalink
Merge pull request #1212 from r-lib/rm-generate_test_samples
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored May 23, 2024
2 parents 6db6eff + 156b6d0 commit 3394099
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 66 deletions.
42 changes: 0 additions & 42 deletions R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,48 +267,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
24 changes: 0 additions & 24 deletions man/generate_test_samples.Rd

This file was deleted.

0 comments on commit 3394099

Please sign in to comment.