syn_adv$adae <- syn_adv$adae[syn_adv$adae$AEBODSYS %in% c("cl A.1", "cl B.1", "cl B.2"), ]
test_that("run works as expected for chevron_t object", {
expect_silent(res <- run(aet04, syn_adv, prune_0 = TRUE))
test_that("run works as expected for chevron_t object when auto_pre = FALSE", {
res <- run(dmt01, proc_data, auto_pre = FALSE)
test_that("run works as expected with argument printed", {
res <- capture_output(tbl <- run(aet02, syn_adv, prune_0 = TRUE, verbose = TRUE, unwrap = FALSE))
test_that("run works as expected with argument printed if the user argument is complicated", {
user_args <- list(prune_0 = TRUE, not_used = iris, lbl_overall = "All Patients", row_split_var = "AEHLT")
res <- capture_output(tbl <- run(aet02, syn_adv, user_args = user_args, verbose = TRUE, unwrap = FALSE))
test_that("run uses the argument passed through the ellipsis in priority", {
test_that("run works as expected with partial match argument", {
res <- capture_output(tbl <- run(aet02, syn_adv, prune_0 = TRUE, verbose = TRUE, unwrap = FALSE, arm_var = "ARM"))
test_that("run displays the symbols when available", {
test_that("run print internal functions when unwrap is TRUE", {
res <- capture_output(tbl <- run(aet02, syn_adv, prune_0 = TRUE, verbose = TRUE, unwrap = TRUE))
test_that("run print internal functions when unwrap is TRUE and standard chevron_tlg has no layout", {
res <- capture_output(tbl <- run(mng01, syn_data, dataset = "adlb", verbose = TRUE, unwrap = TRUE))
test_that("run print internal functions when unwrap is TRUE and the chevron_tlg object is customized", {
ggplot2::ggplot(adam_db$iris, ggplot2::aes(x = Sepal.Length, y = Sepal.Width)) +
res <- capture_output(tbl <- run(custom_chevron, list(iris = iris), verbose = TRUE, unwrap = TRUE))
expect_no_match(out, "Layout function:") # no layout
test_that("run print main and postprocessing functions when unwrap is TRUE and auto_pre is FALSE", {
res <- capture_output(tbl <- run(custom_chevron, iris_ls, verbose = FALSE, unwrap = TRUE, auto_pre = FALSE))
test_that("args_ls works as expected", {
expect_list(res, len = 3, names = "named")
expect_names(names(res), identical.to = c("main", "preprocess", "postprocess"))
test_that("args_ls works as expected when simplify is TRUE", {
res <- expect_silent(args_ls(aet04, simplify = TRUE))
expect_list(res, len = 7, names = "named")
"adam_db", "arm_var", "lbl_overall", "grade_groups", "...", "tlg", "prune_0"
test_that("args_ls works as expected with custom chevron_tlg object", {
preprocess(obj) <- function(adam_db, arm_var = "overwritten", new_arg = "NEW", ...) {
res <- expect_silent(args_ls(obj, simplify = TRUE))
expect_list(res, len = 8, names = "named")
"adam_db", "arm_var", "lbl_overall", "grade_groups", "...", "new_arg", "tlg", "prune_0"
test_that("main setter works as expected", {
test_that("main setter throw an error as expected", {
expect_error(main(obj) <- func, "Variable 'object@main': Must have formal arguments: ....",
test_that("preprocess works as expected", {
test_that("preprocess setter works as expected", {
test_that("preprocess sends an error as expected", {
expect_error(preprocess(obj) <- func, "Variable 'object@preprocess': Must have formal arguments: ....",
test_that("postprocess works as expected", {
test_that("postprocess setter works as expected", {
test_that("postprocess sends an error as expected", {
expect_error(postprocess(obj) <- func, "Variable 'object@postprocess': Must have formal arguments: ....",
test_that("dataset works as expected", {
test_that("dataset setter works as expected", {
test_that("dataset sends an error as expected", {
expect_error(dataset(obj) <- 1, "Must be of type 'character' (or 'NULL')",
test_that("script_funs works as expected in interactive mode", {
res <- expect_silent(script_funs(aet04, adam_db = "data", args = "args_ls"))
test_that("script_funs works as expected", {
test_that("script_funs generates a valid script", {
withr::with_tempfile("tmp", fileext = ".R", {
res_fun <- script_funs(aet04, adam_db = "syn_adv", args = "args_list")
# Creating the object tlg_output in the script.
res <- capture_output(source(tmp, local = TRUE))
expected <- run(aet04, syn_adv, arm_var = "ARM")
test_that("script_funs works for simple template", {
res <- expect_silent(script_funs(chevron_simple(), adam_db = "syn_adv"))
expect_snapshot(print_list(alist(a = 1, b = b, c = xx)))
test_that("print_list works for empty list", {