diff --git a/NAMESPACE b/NAMESPACE index 4b57dd79..06c743c3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -55,11 +55,8 @@ export(is_order_vars) export(is_valid_dtc) export(left_join) export(process_set_values_to) -export(quo_c) -export(quo_not_missing) export(remove_tmp_vars) export(replace_symbol_in_expr) -export(replace_symbol_in_quo) export(replace_values_by_names) export(squote) export(suppress_warning) diff --git a/NEWS.md b/NEWS.md index 8e8f404e..53b93dfe 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,16 @@ ## Breaking Changes +- The following functions/arguments have been deprecated from previous admiral versions using the next phase of the deprecation process: (#288) + - `assert_order_vars()` + - `quo_c()` + - `quo_not_missing()` + - `replace_symbol_in_quo()` + - The `quosures` argument was replaced by the `expressions` argument in `replace_values_by_names()`, `get_source_vars()`, and `vars2chr()`. (#288) +- `assert_function_param()` was deprecated in favor of `assert_function()`. (#264) +- `assert_named_expr()` was deprecated in favor of `assert_expr_list()`. (#264) +- `assert_has_variables()` was deprecated in favor of `assert_data_frame()`. (#264) + ## Documentation - Guidance around issues and merging updated (#286) diff --git a/R/assertions.R b/R/assertions.R index 9f83cc95..1aa6b09f 100644 --- a/R/assertions.R +++ b/R/assertions.R @@ -545,9 +545,7 @@ assert_vars <- function(arg, expect_names = FALSE, optional = FALSE) { assert_order_vars <- function(arg, optional = FALSE) { assert_logical_scalar(optional) - deprecate_warn("0.4.0", "assert_order_vars()", "assert_expr_list()") - - assert_expr_list(arg, optional = optional) + deprecate_stop("0.4.0", "assert_order_vars()", "assert_expr_list()") } #' Is an Argument an Integer Scalar? @@ -871,10 +869,15 @@ assert_named <- function(arg, optional = FALSE) { #' Assert Argument is a Named List of Expressions #' +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' This function is *deprecated*, please use `assert_expr_list()` instead. +#' #' @inheritParams assert_data_frame #' -#' @keywords assertion -#' @family assertion +#' @keywords deprecated +#' @family deprecated #' #' @return #' The function throws an error if `arg` is not a named `list` of expression or @@ -882,30 +885,19 @@ assert_named <- function(arg, optional = FALSE) { #' #' @export assert_named_exprs <- function(arg, optional = FALSE) { - assert_logical_scalar(optional) - - if (optional && is.null(arg)) { - return(invisible(arg)) - } - - if (!is.list(arg) || - !all(map_lgl(arg, ~ is.language(.x) | is.logical(.x))) || - any(names(arg) == "")) { - err_msg <- sprintf( - "`%s` must be a named list of expressions created using `rlang::exprs()` but is %s", - arg_name(substitute(arg)), - what_is_it(arg) - ) - abort(err_msg) - } - - invisible(arg) + deprecate_warn("0.5.0", "assert_named_exprs()", "assert_expr_list()", always = TRUE) + assert_expr_list(arg = arg, named = TRUE) } #' Does a Dataset Contain All Required Variables? #' #' Checks if a dataset contains all required variables #' +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' This function is *deprecated*, please use `assert_data_frame()` instead. +#' #' @param dataset A `data.frame` #' @param required_vars A `character` vector of variable names #' @@ -915,31 +907,17 @@ assert_named_exprs <- function(arg, optional = FALSE) { #' #' @export #' -#' @keywords assertion -#' @family assertion -#' @examples -#' library(admiral.test) -#' data(admiral_dm) -#' -#' assert_has_variables(admiral_dm, "STUDYID") -#' -#' try(assert_has_variables(admiral_dm, "AVAL")) +#' @keywords deprecated +#' @family deprecated assert_has_variables <- function(dataset, required_vars) { - is_missing <- !required_vars %in% colnames(dataset) - if (any(is_missing)) { - missing_vars <- required_vars[is_missing] - if (length(missing_vars) == 1L) { - err_msg <- paste0("Required variable `", missing_vars, "` is missing.") - } else { - err_msg <- paste0( - "Required variables ", - enumerate(missing_vars), - " are missing." - ) - } - abort(err_msg) - } - invisible(dataset) + deprecate_warn("0.5.0", "assert_has_variables()", "assert_data_frame()") + assert_data_frame( + arg = dataset, + required_vars = set_names( + exprs(!!!syms(required_vars)), + names(required_vars) + ) + ) } #' Is Argument a Function? @@ -947,6 +925,11 @@ assert_has_variables <- function(dataset, required_vars) { #' Checks if the argument is a function and if all expected arguments are #' provided by the function. #' +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' This function is *deprecated*, please use `assert_function_param()` instead. +#' #' @param arg A function argument to be checked #' #' @param params A character vector of expected argument names @@ -965,8 +948,8 @@ assert_has_variables <- function(dataset, required_vars) { #' #' @export #' -#' @keywords assertion -#' @family assertion +#' @keywords deprecated +#' @family deprecated #' @examples #' example_fun <- function(fun) { #' assert_function(fun, params = c("x")) @@ -1029,32 +1012,9 @@ assert_function <- function(arg, params = NULL, optional = FALSE) { #' the function given by `arg` #' #' @export -#' -#' @examples -#' hello <- function(name) { -#' print(sprintf("Hello %s", name)) -#' } -#' -#' assert_function_param("hello", "name") -#' -#' try(assert_function_param("hello", "surname")) assert_function_param <- function(arg, params) { - assert_character_scalar(arg) - assert_character_vector(params) - fun <- match.fun(arg) - - is_param <- params %in% names(formals(fun)) - if (!all(is_param)) { - txt <- if (sum(!is_param) == 1L) { - "%s is not an argument of `%s()`" - } else { - "%s are not arguments of `%s()`" - } - err_msg <- sprintf(txt, enumerate(params[!is_param]), arg) - abort(err_msg) - } - - invisible(arg) + deprecate_warn("0.5.0", "assert_function_param()", "assert_function()", always = TRUE) + assert_function(arg = arg, params = params) } #' Asserts That a Parameter is Provided in the Expected Unit diff --git a/R/dev_utilities.R b/R/dev_utilities.R index 4d37a178..fb540c79 100644 --- a/R/dev_utilities.R +++ b/R/dev_utilities.R @@ -162,12 +162,11 @@ contains_vars <- function(arg) { #' vars2chr(exprs(USUBJID, AVAL)) vars2chr <- function(expressions, quosures) { if (!missing(quosures)) { - deprecate_warn( + deprecate_stop( "0.10.0", "vars2chr(quosures = )", "vars2chr(expressions = )" ) - expressions <- map(quosures, rlang::quo_get_expr) } rlang::set_names( map_chr(expressions, as_string), diff --git a/R/get.R b/R/get.R index e647e983..c209a564 100644 --- a/R/get.R +++ b/R/get.R @@ -86,12 +86,11 @@ get_duplicates <- function(x) { #' @export get_source_vars <- function(expressions, quosures) { if (!missing(quosures)) { - deprecate_warn( + deprecate_stop( "0.10.0", "get_source_vars(quosures = )", "get_source_vars(expressions = )" ) - expressions <- map(quosures, rlang::quo_get_expr) } assert_varval_list(expressions, optional = TRUE) diff --git a/R/quo.R b/R/quo.R index a5870a6f..10fccb9f 100644 --- a/R/quo.R +++ b/R/quo.R @@ -1,30 +1,3 @@ -#' Concatenate One or More Quosure(s) -#' -#' `r lifecycle::badge("deprecated")` -#' -#' This function is *deprecated*, please use `expr_c()` instead. -#' -#' @param ... One or more objects of class `quosure` or `quosures` -#' -#' @return An object of class `quosures` -#' -#' -#' @keywords deprecated -#' @family deprecated -#' -#' @export -quo_c <- function(...) { - deprecate_stop( - "0.3.0", - "quo_c()", - "expr_c()", - details = paste( - "Expressions created by `exprs()` must be used", - "instead of quosures created by `vars()`." - ) - ) -} - #' Concatenate One or More Expressions #' #' @param ... One or more expressions or list of expressions @@ -53,30 +26,6 @@ expr_c <- function(...) { inputs[!is_null] } -#' Check Whether an Argument Is Not a Quosure of a Missing Argument -#' -#' @param x Test object -#' -#' @return TRUE or error. -#' -#' -#' @keywords deprecated -#' @family deprecated -#' -#' @export -quo_not_missing <- function(x) { - deprecate_stop( - "0.3.0", - "quo_not_missing()", - details = paste( - "Due to changing from `vars()` to `exprs()` the function is no longer required.", - "It will be removed in future.", - sep = "\n" - ) - ) -} - - #' Replace Expression Value with Name #' #' @param expressions A list of expressions @@ -101,7 +50,6 @@ replace_values_by_names <- function(expressions, quosures) { "replace_values_by_names(quosures = )", "replace_values_by_names(expressions = )" ) - expressions <- map(quosures, rlang::quo_get_expr) } if (is.null(names(expressions))) { return(expressions) @@ -114,40 +62,6 @@ replace_values_by_names <- function(expressions, quosures) { }) } -#' Replace Symbols in a Quosure -#' -#' `r lifecycle::badge("deprecated")` -#' -#' This function is *deprecated*, please use `replace_symbol_in_expr()` instead. -#' -#' @param quosure Quosure -#' -#' @param target Target symbol -#' -#' @param replace Replacing symbol -#' -#' -#' @return The quosure where every occurrence of the symbol `target` is replaced -#' by `replace` -#' -#' @keywords deprecated -#' @family deprecated -#' -#' @export -replace_symbol_in_quo <- function(quosure, - target, - replace) { - deprecate_stop( - "0.3.0", - "replace_symbol_in_quo()", - "replace_symbol_in_expr()", - details = paste( - "Expressions created by `exprs()` must be used", - "instead of quosures created by `vars()`." - ) - ) -} - #' Replace Symbols in an Expression #' #' Replace symbols in an expression diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 4e7f8407..0ad987d4 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,4 +1,4 @@ -pandoc: 2.11.4 +pandoc: 2.19.2 pkgdown: 2.0.7 pkgdown_sha: ~ articles: @@ -7,10 +7,11 @@ articles: git_usage: git_usage.html pr_review_guidance: pr_review_guidance.html programming_strategy: programming_strategy.html + rcmd_issues: rcmd_issues.html release_strategy: release_strategy.html unit_test_guidance: unit_test_guidance.html writing_vignettes: writing_vignettes.html -last_built: 2023-04-12T17:21Z +last_built: 2023-06-26T16:08Z urls: reference: https://pharmaverse.github.io/admiraldev/devel/reference article: https://pharmaverse.github.io/admiraldev/devel/articles diff --git a/man/assert_atomic_vector.Rd b/man/assert_atomic_vector.Rd index 5314c62e..76fca001 100644 --- a/man/assert_atomic_vector.Rd +++ b/man/assert_atomic_vector.Rd @@ -38,13 +38,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_character_scalar.Rd b/man/assert_character_scalar.Rd index a4c8539f..cc0db79c 100644 --- a/man/assert_character_scalar.Rd +++ b/man/assert_character_scalar.Rd @@ -68,13 +68,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_character_vector.Rd b/man/assert_character_vector.Rd index 08e20d99..0e114558 100644 --- a/man/assert_character_vector.Rd +++ b/man/assert_character_vector.Rd @@ -50,13 +50,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_data_frame.Rd b/man/assert_data_frame.Rd index 0b2a8c7d..ec5d6e92 100644 --- a/man/assert_data_frame.Rd +++ b/man/assert_data_frame.Rd @@ -56,13 +56,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_date_vector.Rd b/man/assert_date_vector.Rd index e9f1e2a9..7aee4078 100644 --- a/man/assert_date_vector.Rd +++ b/man/assert_date_vector.Rd @@ -39,13 +39,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_expr.Rd b/man/assert_expr.Rd index aaa51970..579b6cd4 100644 --- a/man/assert_expr.Rd +++ b/man/assert_expr.Rd @@ -29,13 +29,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr_list}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_expr_list.Rd b/man/assert_expr_list.Rd index 790f8ec6..effb5d5d 100644 --- a/man/assert_expr_list.Rd +++ b/man/assert_expr_list.Rd @@ -49,13 +49,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_filter_cond.Rd b/man/assert_filter_cond.Rd index 797cb61c..cdc39603 100644 --- a/man/assert_filter_cond.Rd +++ b/man/assert_filter_cond.Rd @@ -48,13 +48,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr_list}()}, \code{\link{assert_expr}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_function.Rd b/man/assert_function.Rd index 728746ff..2f7d09ed 100644 --- a/man/assert_function.Rd +++ b/man/assert_function.Rd @@ -24,6 +24,11 @@ The function throws an error } } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +This function is \emph{deprecated}, please use \code{assert_function_param()} instead. +} +\details{ Checks if the argument is a function and if all expected arguments are provided by the function. } @@ -39,32 +44,10 @@ try(example_fun(1)) try(example_fun(sum)) } \seealso{ -Checks for valid input and returns warning or errors messages: -\code{\link{assert_atomic_vector}()}, -\code{\link{assert_character_scalar}()}, -\code{\link{assert_character_vector}()}, -\code{\link{assert_data_frame}()}, -\code{\link{assert_date_vector}()}, -\code{\link{assert_expr_list}()}, -\code{\link{assert_expr}()}, -\code{\link{assert_filter_cond}()}, -\code{\link{assert_function_param}()}, +Other deprecated: \code{\link{assert_has_variables}()}, -\code{\link{assert_integer_scalar}()}, -\code{\link{assert_list_element}()}, -\code{\link{assert_list_of}()}, -\code{\link{assert_logical_scalar}()}, \code{\link{assert_named_exprs}()}, -\code{\link{assert_named}()}, -\code{\link{assert_numeric_vector}()}, -\code{\link{assert_one_to_one}()}, -\code{\link{assert_param_does_not_exist}()}, -\code{\link{assert_s3_class}()}, -\code{\link{assert_same_type}()}, -\code{\link{assert_symbol}()}, -\code{\link{assert_unit}()}, -\code{\link{assert_vars}()}, -\code{\link{assert_varval_list}()} +\code{\link{assert_order_vars}()} } -\concept{assertion} -\keyword{assertion} +\concept{deprecated} +\keyword{deprecated} diff --git a/man/assert_function_param.Rd b/man/assert_function_param.Rd index 93a69636..d4a6edbc 100644 --- a/man/assert_function_param.Rd +++ b/man/assert_function_param.Rd @@ -18,15 +18,6 @@ the function given by \code{arg} \description{ Assert Argument is a Parameter of a Function } -\examples{ -hello <- function(name) { - print(sprintf("Hello \%s", name)) -} - -assert_function_param("hello", "name") - -try(assert_function_param("hello", "surname")) -} \seealso{ Checks for valid input and returns warning or errors messages: \code{\link{assert_atomic_vector}()}, @@ -37,13 +28,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr_list}()}, \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_has_variables.Rd b/man/assert_has_variables.Rd index 98fd5c4e..86b8f41c 100644 --- a/man/assert_has_variables.Rd +++ b/man/assert_has_variables.Rd @@ -16,43 +16,18 @@ The function throws an error if any of the required variables are missing in the input dataset. Otherwise, the dataset is returned invisibly. } \description{ -Checks if a dataset contains all required variables -} -\examples{ -library(admiral.test) -data(admiral_dm) - -assert_has_variables(admiral_dm, "STUDYID") +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -try(assert_has_variables(admiral_dm, "AVAL")) +This function is \emph{deprecated}, please use \code{assert_data_frame()} instead. +} +\details{ +Checks if a dataset contains all required variables } \seealso{ -Checks for valid input and returns warning or errors messages: -\code{\link{assert_atomic_vector}()}, -\code{\link{assert_character_scalar}()}, -\code{\link{assert_character_vector}()}, -\code{\link{assert_data_frame}()}, -\code{\link{assert_date_vector}()}, -\code{\link{assert_expr_list}()}, -\code{\link{assert_expr}()}, -\code{\link{assert_filter_cond}()}, -\code{\link{assert_function_param}()}, +Other deprecated: \code{\link{assert_function}()}, -\code{\link{assert_integer_scalar}()}, -\code{\link{assert_list_element}()}, -\code{\link{assert_list_of}()}, -\code{\link{assert_logical_scalar}()}, \code{\link{assert_named_exprs}()}, -\code{\link{assert_named}()}, -\code{\link{assert_numeric_vector}()}, -\code{\link{assert_one_to_one}()}, -\code{\link{assert_param_does_not_exist}()}, -\code{\link{assert_s3_class}()}, -\code{\link{assert_same_type}()}, -\code{\link{assert_symbol}()}, -\code{\link{assert_unit}()}, -\code{\link{assert_vars}()}, -\code{\link{assert_varval_list}()} +\code{\link{assert_order_vars}()} } -\concept{assertion} -\keyword{assertion} +\concept{deprecated} +\keyword{deprecated} diff --git a/man/assert_integer_scalar.Rd b/man/assert_integer_scalar.Rd index 05d59895..d927a12a 100644 --- a/man/assert_integer_scalar.Rd +++ b/man/assert_integer_scalar.Rd @@ -47,12 +47,9 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_list_element.Rd b/man/assert_list_element.Rd index 7167d04b..b8062ebc 100644 --- a/man/assert_list_element.Rd +++ b/man/assert_list_element.Rd @@ -50,12 +50,9 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_list_of.Rd b/man/assert_list_of.Rd index 6541616b..ed5092e6 100644 --- a/man/assert_list_of.Rd +++ b/man/assert_list_of.Rd @@ -52,12 +52,9 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_logical_scalar.Rd b/man/assert_logical_scalar.Rd index 640fed0f..ece4c6a0 100644 --- a/man/assert_logical_scalar.Rd +++ b/man/assert_logical_scalar.Rd @@ -45,12 +45,9 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_named.Rd b/man/assert_named.Rd index 24a486ee..c10b6407 100644 --- a/man/assert_named.Rd +++ b/man/assert_named.Rd @@ -41,13 +41,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, \code{\link{assert_param_does_not_exist}()}, diff --git a/man/assert_named_exprs.Rd b/man/assert_named_exprs.Rd index e81213a2..70b36399 100644 --- a/man/assert_named_exprs.Rd +++ b/man/assert_named_exprs.Rd @@ -17,35 +17,15 @@ The function throws an error if \code{arg} is not a named \code{list} of express returns the input invisibly otherwise } \description{ -Assert Argument is a Named List of Expressions +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +This function is \emph{deprecated}, please use \code{assert_expr_list()} instead. } \seealso{ -Checks for valid input and returns warning or errors messages: -\code{\link{assert_atomic_vector}()}, -\code{\link{assert_character_scalar}()}, -\code{\link{assert_character_vector}()}, -\code{\link{assert_data_frame}()}, -\code{\link{assert_date_vector}()}, -\code{\link{assert_expr_list}()}, -\code{\link{assert_expr}()}, -\code{\link{assert_filter_cond}()}, -\code{\link{assert_function_param}()}, +Other deprecated: \code{\link{assert_function}()}, \code{\link{assert_has_variables}()}, -\code{\link{assert_integer_scalar}()}, -\code{\link{assert_list_element}()}, -\code{\link{assert_list_of}()}, -\code{\link{assert_logical_scalar}()}, -\code{\link{assert_named}()}, -\code{\link{assert_numeric_vector}()}, -\code{\link{assert_one_to_one}()}, -\code{\link{assert_param_does_not_exist}()}, -\code{\link{assert_s3_class}()}, -\code{\link{assert_same_type}()}, -\code{\link{assert_symbol}()}, -\code{\link{assert_unit}()}, -\code{\link{assert_vars}()}, -\code{\link{assert_varval_list}()} +\code{\link{assert_order_vars}()} } -\concept{assertion} -\keyword{assertion} +\concept{deprecated} +\keyword{deprecated} diff --git a/man/assert_numeric_vector.Rd b/man/assert_numeric_vector.Rd index a12da5ca..34a855aa 100644 --- a/man/assert_numeric_vector.Rd +++ b/man/assert_numeric_vector.Rd @@ -39,13 +39,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_one_to_one}()}, \code{\link{assert_param_does_not_exist}()}, diff --git a/man/assert_one_to_one.Rd b/man/assert_one_to_one.Rd index 09a71367..67dfd455 100644 --- a/man/assert_one_to_one.Rd +++ b/man/assert_one_to_one.Rd @@ -32,13 +32,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_param_does_not_exist}()}, diff --git a/man/assert_order_vars.Rd b/man/assert_order_vars.Rd index b17ce75a..48c00578 100644 --- a/man/assert_order_vars.Rd +++ b/man/assert_order_vars.Rd @@ -27,9 +27,9 @@ using \code{exprs()} } \seealso{ Other deprecated: -\code{\link{quo_c}()}, -\code{\link{quo_not_missing}()}, -\code{\link{replace_symbol_in_quo}()} +\code{\link{assert_function}()}, +\code{\link{assert_has_variables}()}, +\code{\link{assert_named_exprs}()} } \concept{deprecated} \keyword{deprecated} diff --git a/man/assert_param_does_not_exist.Rd b/man/assert_param_does_not_exist.Rd index c51ec8df..bb2f839c 100644 --- a/man/assert_param_does_not_exist.Rd +++ b/man/assert_param_does_not_exist.Rd @@ -39,13 +39,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_s3_class.Rd b/man/assert_s3_class.Rd index 1726392b..fd41a9a6 100644 --- a/man/assert_s3_class.Rd +++ b/man/assert_s3_class.Rd @@ -43,13 +43,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_same_type.Rd b/man/assert_same_type.Rd index c12d7c6c..797bab58 100644 --- a/man/assert_same_type.Rd +++ b/man/assert_same_type.Rd @@ -43,13 +43,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_symbol.Rd b/man/assert_symbol.Rd index 52819dfb..0ff6288f 100644 --- a/man/assert_symbol.Rd +++ b/man/assert_symbol.Rd @@ -49,13 +49,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_unit.Rd b/man/assert_unit.Rd index 52820720..b72051d9 100644 --- a/man/assert_unit.Rd +++ b/man/assert_unit.Rd @@ -45,13 +45,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_vars.Rd b/man/assert_vars.Rd index 596f418a..873b1cce 100644 --- a/man/assert_vars.Rd +++ b/man/assert_vars.Rd @@ -57,13 +57,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/assert_varval_list.Rd b/man/assert_varval_list.Rd index 343fe57c..2dc74ae7 100644 --- a/man/assert_varval_list.Rd +++ b/man/assert_varval_list.Rd @@ -56,13 +56,10 @@ Checks for valid input and returns warning or errors messages: \code{\link{assert_expr}()}, \code{\link{assert_filter_cond}()}, \code{\link{assert_function_param}()}, -\code{\link{assert_function}()}, -\code{\link{assert_has_variables}()}, \code{\link{assert_integer_scalar}()}, \code{\link{assert_list_element}()}, \code{\link{assert_list_of}()}, \code{\link{assert_logical_scalar}()}, -\code{\link{assert_named_exprs}()}, \code{\link{assert_named}()}, \code{\link{assert_numeric_vector}()}, \code{\link{assert_one_to_one}()}, diff --git a/man/quo_c.Rd b/man/quo_c.Rd deleted file mode 100644 index 672877ae..00000000 --- a/man/quo_c.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/quo.R -\name{quo_c} -\alias{quo_c} -\title{Concatenate One or More Quosure(s)} -\usage{ -quo_c(...) -} -\arguments{ -\item{...}{One or more objects of class \code{quosure} or \code{quosures}} -} -\value{ -An object of class \code{quosures} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -} -\details{ -This function is \emph{deprecated}, please use \code{expr_c()} instead. -} -\seealso{ -Other deprecated: -\code{\link{assert_order_vars}()}, -\code{\link{quo_not_missing}()}, -\code{\link{replace_symbol_in_quo}()} -} -\concept{deprecated} -\keyword{deprecated} diff --git a/man/quo_not_missing.Rd b/man/quo_not_missing.Rd deleted file mode 100644 index 7e45b673..00000000 --- a/man/quo_not_missing.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/quo.R -\name{quo_not_missing} -\alias{quo_not_missing} -\title{Check Whether an Argument Is Not a Quosure of a Missing Argument} -\usage{ -quo_not_missing(x) -} -\arguments{ -\item{x}{Test object} -} -\value{ -TRUE or error. -} -\description{ -Check Whether an Argument Is Not a Quosure of a Missing Argument -} -\seealso{ -Other deprecated: -\code{\link{assert_order_vars}()}, -\code{\link{quo_c}()}, -\code{\link{replace_symbol_in_quo}()} -} -\concept{deprecated} -\keyword{deprecated} diff --git a/man/replace_symbol_in_quo.Rd b/man/replace_symbol_in_quo.Rd deleted file mode 100644 index ccbb3200..00000000 --- a/man/replace_symbol_in_quo.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/quo.R -\name{replace_symbol_in_quo} -\alias{replace_symbol_in_quo} -\title{Replace Symbols in a Quosure} -\usage{ -replace_symbol_in_quo(quosure, target, replace) -} -\arguments{ -\item{quosure}{Quosure} - -\item{target}{Target symbol} - -\item{replace}{Replacing symbol} -} -\value{ -The quosure where every occurrence of the symbol \code{target} is replaced -by \code{replace} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -} -\details{ -This function is \emph{deprecated}, please use \code{replace_symbol_in_expr()} instead. -} -\seealso{ -Other deprecated: -\code{\link{assert_order_vars}()}, -\code{\link{quo_c}()}, -\code{\link{quo_not_missing}()} -} -\concept{deprecated} -\keyword{deprecated} diff --git a/tests/testthat/test-assertions.R b/tests/testthat/test-assertions.R index 0a0fd597..8d414cee 100644 --- a/tests/testthat/test-assertions.R +++ b/tests/testthat/test-assertions.R @@ -1,29 +1,33 @@ # assert_has_variables ---- -## Test 1: error if a required variable is missing ---- -test_that("assert_has_variables Test 1: error if a required variable is missing", { +## Test 1: error if a required variable is missing (deprecation warn) ---- +test_that("assert_has_variables Test 1: error if a required variable is missing (deprecation warn)", { # nolint data <- tibble::tribble( ~USUBJID, "1" ) - expect_error( - assert_has_variables(data, "TRT01P"), - "Required variable `TRT01P` is missing." + expect_warning( + try(assert_has_variables(data, "TRT01P"), silent = TRUE), + class = "lifecycle_warning_deprecated" ) - expect_error( - assert_has_variables(admiral.test::admiral_dm, c("TRT01P", "AVAL")) + expect_warning( + try(assert_has_variables(admiral.test::admiral_dm, c("TRT01P", "AVAL")), silent = TRUE), + class = "lifecycle_warning_deprecated" ) }) -## Test 2: no error if a required variable exists ---- -test_that("assert_has_variables Test 2: no error if a required variable exists", { +## Test 2: no error if a required variable exists (deprecation warn) ---- +test_that("assert_has_variables Test 2: no error if a required variable exists (deprecation warn)", { # nolint data <- tibble::tribble( ~USUBJID, "1" ) - expect_error(assert_has_variables(data, "USUBJID"), NA) + expect_warning( + try(assert_has_variables(data, "USUBJID"), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) }) # assert_filter_cond ---- @@ -491,9 +495,9 @@ test_that("assert_vars Test 31: error if some elements of `arg` are not unquoted # assert_order_vars ---- ## Test 32: warn if assert_order_vars() is called ---- test_that("assert_order_vars Test 32: warn if assert_order_vars() is called", { - expect_warning( + expect_error( assert_order_vars(arg <- exprs(USUBJID)), - class = "lifecycle_warning_deprecated" + class = "lifecycle_error_deprecated" ) }) @@ -712,8 +716,8 @@ test_that("assert_named Test 51: error if no elements are named", { }) # assert_named_exprs ---- -## Test 52: error if `arg` is not a named list of expressions ---- -test_that("assert_named_exprs Test 52: error if `arg` is not a named list of expressions", { +## Test 52: error if `arg` is not a named list of expressions (deprecation warn) ---- +test_that("assert_named_exprs Test 52: error if `arg` is not a named list of expressions (deprecation warn)", { # nolint example_fun <- function(arg) { assert_named_exprs(arg) } @@ -721,33 +725,50 @@ test_that("assert_named_exprs Test 52: error if `arg` is not a named list of exp arg <- list("test") names(arg) <- c("") - expect_error(example_fun(5)) - expect_error(example_fun(admiral.test::admiral_dm)) - expect_error(example_fun(list(1, 2, TRUE))) - expect_error(example_fun(arg)) + expect_warning( + try(example_fun(5), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) + expect_warning( + try(example_fun(admiral.test::admiral_dm), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) + expect_warning( + try(example_fun(list(1, 2, TRUE)), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) + expect_warning( + try(example_fun(arg), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) }) -## Test 53: no error if `arg` is NULL and optional is TRUE ---- -test_that("assert_named_exprs Test 53: no error if `arg` is NULL and optional is TRUE", { +## Test 53: no error if `arg` is NULL and optional is TRUE (deprecation warn) ---- +test_that("assert_named_exprs Test 53: no error if `arg` is NULL and optional is TRUE (deprecation warn)", { # nolint example_fun <- function(arg) { assert_named_exprs(arg, optional = TRUE) } - expect_invisible( - example_fun(NULL) + expect_warning( + try(example_fun(NULL), silent = TRUE), + class = "lifecycle_warning_deprecated" ) }) -## Test 54: no error if `arg` is a named list of expressions ---- -test_that("assert_named_exprs Test 54: no error if `arg` is a named list of expressions", { +## Test 54: no error if `arg` is a named list of expressions (deprecation warn) ---- +test_that("assert_named_exprs Test 54: no error if `arg` is a named list of expressions (deprecation warn)", { # nolint example_fun <- function(arg) { assert_named_exprs(arg) } - expect_invisible( - example_fun( - rlang::exprs() - ) + expect_warning( + try( + example_fun( + rlang::exprs() + ), + silent = TRUE + ), + class = "lifecycle_warning_deprecated" ) }) @@ -799,23 +820,32 @@ test_that("assert_function Test 58: error if `params` is missing with no defau # assert_function_param ---- -## Test 59: no error if `arg` is a parameter of a function ---- -test_that("assert_function_param Test 59: no error if `arg` is a parameter of a function", { +## Test 59: no error if `arg` is a parameter of a function (deprecation warn) ---- +test_that("assert_function_param Test 59: no error if `arg` is a parameter of a function (deprecation warn)", { # nolint hello <- function(name) { print(sprintf("Hello %s", name)) } - expect_invisible(assert_function_param("hello", "name")) + expect_warning( + try(assert_function_param("hello", params = "name"), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) }) -## Test 60: error if expected function parameters are missing ---- -test_that("assert_function_param Test 60: error if expected function parameters are missing", { +## Test 60: error if expected function parameters are missing (deprecation warn) ---- +test_that("assert_function_param Test 60: error if expected function parameters are missing (deprecation warn)", { # nolint hello <- function(name) { print(sprintf("Hello %s", name)) } - expect_error(assert_function_param("hello", "surname")) - expect_error(assert_function_param("hello", params = c("surname", "firstname"))) + expect_warning( + try(assert_function_param("hello", "surname"), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) + expect_warning( + try(assert_function_param("hello", params = c("surname", "firstname")), silent = TRUE), + class = "lifecycle_warning_deprecated" + ) }) # assert_unit ---- diff --git a/tests/testthat/test-dev_utilities.R b/tests/testthat/test-dev_utilities.R index 0c83d82f..b440ad8f 100644 --- a/tests/testthat/test-dev_utilities.R +++ b/tests/testthat/test-dev_utilities.R @@ -79,9 +79,9 @@ test_that("vars2chr Test 8: returns character vector", { ## Test 9: warning if quosures argument is used ---- test_that("vars2chr Test 9: warning if quosures argument is used", { - expect_warning( + expect_error( vars2chr(quosures = rlang::quos(STUDYID, USUBJID)), - class = "lifecycle_warning_deprecated" + class = "lifecycle_error_deprecated" ) }) diff --git a/tests/testthat/test-get.R b/tests/testthat/test-get.R index 5389b9d6..1f53a726 100644 --- a/tests/testthat/test-get.R +++ b/tests/testthat/test-get.R @@ -63,9 +63,9 @@ test_that("get_source_vars Test 5: NULL returns NULL", { ## Test 6: warning if quosures argument is used ---- test_that("get_source_vars Test 6: warning if quosures argument is used", { - expect_warning( + expect_error( get_source_vars(quosures = rlang::quos(DTHDOM = "AE", DTHSEQ = AESEQ)), - class = "lifecycle_warning_deprecated" + class = "lifecycle_error_deprecated" ) }) ## Test 7: no source vars returns NULL ---- diff --git a/tests/testthat/test-quo.R b/tests/testthat/test-quo.R index 579cd728..fdeacc4e 100644 --- a/tests/testthat/test-quo.R +++ b/tests/testthat/test-quo.R @@ -1,40 +1,6 @@ -# quo_c ---- -## Test 1: issues deprecation warning ---- -test_that("quo_c Test 1: issues deprecation warning", { - expect_error( - quo_c(quo(USUBJID), quo(STUDYID)), - class = "lifecycle_error_deprecated" - ) -}) - -## Test 2: `quo_c` works in concatenating and indexing quosures ---- -test_that("quo_c Test 2: `quo_c` works in concatenating and indexing quosures", { - x <- quo(USUBJID) - y <- quo(STUDYID) - - expect_error( - quo_c(x, NULL, y)[[1]], - class = "lifecycle_error_deprecated" - ) - expect_error( - object = quo_c(x, NULL, y)[[2]], - class = "lifecycle_error_deprecated" - ) -}) - -## Test 3: `quo_c` returns error if non-quosures are input ---- -test_that("quo_c Test 3: `quo_c` returns error if non-quosures are input", { - USUBJID <- "01-701-1015" # nolint - - expect_error( - object = quo_c(quo(USUBJID), USUBJID), - class = "lifecycle_error_deprecated" - ) -}) - # expr_c ---- -## Test 4: concatenating and indexing expressions ---- -test_that("expr_c Test 4: concatenating and indexing expressions", { +## Test 1: concatenating and indexing expressions ---- +test_that("expr_c Test 1: concatenating and indexing expressions", { x <- expr(USUBJID) y <- expr(STUDYID) @@ -48,54 +14,32 @@ test_that("expr_c Test 4: concatenating and indexing expressions", { ) }) -## Test 5: concatenating named list of expressions ---- -test_that("expr_c Test 5: concatenating named list of expressions", { +## Test 2: concatenating named list of expressions ---- +test_that("expr_c Test 2: concatenating named list of expressions", { expect_equal( expected = exprs(PARAMCD = "DOSE", PARAMN = 1), object = expr_c(exprs(PARAMCD = "DOSE", PARAMN = 1, NULL)) ) }) -## Test 6: concatenating list and single expression ---- -test_that("expr_c Test 6: concatenating list and single expression", { +## Test 3: concatenating list and single expression ---- +test_that("expr_c Test 3: concatenating list and single expression", { expect_equal( expected = exprs(PARAMCD, PARAM, AVAL), object = expr_c(exprs(PARAMCD, PARAM), expr(AVAL)) ) }) -## Test 7: returns error if non-expressions are input ---- -test_that("expr_c Test 7: returns error if non-expressions are input", { +## Test 4: returns error if non-expressions are input ---- +test_that("expr_c Test 4: returns error if non-expressions are input", { expect_error( object = expr_c(expr(USUBJID), mean) ) }) -# quo_not_missing ---- -## Test 8: issues deprecation warning ---- -test_that("quo_not_missing Test 8: issues deprecation warning", { - test_fun <- function(x) { - x <- enquo(x) - !isTRUE(quo_not_missing(x)) - } - expect_error( - test_fun(my_variable), - class = "lifecycle_error_deprecated" - ) -}) - -## Test 9: `quo_not_missing` throws an Error if missing argument ---- -test_that("quo_not_missing Test 9: `quo_not_missing` throws an Error if missing argument", { - test_fun <- function(x) { - x <- enquo(x) - isTrue(quo_not_missing(x)) - } - expect_error(test_fun()) # missing argument -> throws error -}) - # replace_values_by_names ---- -## Test 10: names of expressions replace value ---- -test_that("replace_values_by_names Test 10: names of expressions replace value", { +## Test 5: names of expressions replace value ---- +test_that("replace_values_by_names Test 5: names of expressions replace value", { z <- exprs(USUBJID, STUDYID) z_noname <- replace_values_by_names(z) @@ -122,8 +66,8 @@ test_that("replace_values_by_names Test 10: names of expressions replace value", ) }) -## Test 11: names of argument is NULL ---- -test_that("replace_values_by_names Test 11: names of argument is NULL", { +## Test 6: names of argument is NULL ---- +test_that("replace_values_by_names Test 6: names of argument is NULL", { z <- exprs(USUBJID, STUDYID) names(z) <- NULL @@ -133,26 +77,17 @@ test_that("replace_values_by_names Test 11: names of argument is NULL", { ) }) -## Test 12: warning if quosures argument is used ---- -test_that("replace_values_by_names Test 12: warning if quosures argument is used", { +## Test 7: warning if quosures argument is used ---- +test_that("replace_values_by_names Test 7: warning if quosures argument is used", { expect_error( replace_values_by_names(quosures = rlang::quos(STUDYID, USUBJID)), class = "lifecycle_error_deprecated" ) }) -# replace_symbol_in_quo ---- -## Test 13: error if called ---- -test_that("replace_symbol_in_quo Test 13: error if called", { - expect_error( - replace_symbol_in_quo(), - class = "lifecycle_error_deprecated" - ) -}) - # replace_symbol_in_expr ---- -## Test 14: symbol is replaced ---- -test_that("replace_symbol_in_expr Test 14: symbol is replaced", { +## Test 8: symbol is replaced ---- +test_that("replace_symbol_in_expr Test 8: symbol is replaced", { expect_equal( expected = expr(AVAL.join), object = replace_symbol_in_expr( @@ -163,8 +98,8 @@ test_that("replace_symbol_in_expr Test 14: symbol is replaced", { ) }) -## Test 15: partial match is not replaced ---- -test_that("replace_symbol_in_expr Test 15: partial match is not replaced", { +## Test 9: partial match is not replaced ---- +test_that("replace_symbol_in_expr Test 9: partial match is not replaced", { expect_equal( expected = expr(AVALC), object = replace_symbol_in_expr( @@ -175,8 +110,8 @@ test_that("replace_symbol_in_expr Test 15: partial match is not replaced", { ) }) -## Test 16: symbol in expression is replaced ---- -test_that("replace_symbol_in_expr Test 16: symbol in expression is replaced", { +## Test 10: symbol in expression is replaced ---- +test_that("replace_symbol_in_expr Test 10: symbol in expression is replaced", { expect_equal( expected = expr(desc(AVAL.join)), object = replace_symbol_in_expr( @@ -188,8 +123,8 @@ test_that("replace_symbol_in_expr Test 16: symbol in expression is replaced", { }) # add_suffix_to_vars ---- -## Test 17: with single variable ---- -test_that("add_suffix_to_vars Test 17: with single variable", { +## Test 11: with single variable ---- +test_that("add_suffix_to_vars Test 11: with single variable", { expect_equal( expected = exprs(ADT, desc(AVAL.join), AVALC), object = add_suffix_to_vars( @@ -200,8 +135,8 @@ test_that("add_suffix_to_vars Test 17: with single variable", { ) }) -## Test 18: with more than one variable ---- -test_that("add_suffix_to_vars Test 18: with more than one variable", { +## Test 12: with more than one variable ---- +test_that("add_suffix_to_vars Test 12: with more than one variable", { expect_equal( expected = exprs(ADT, desc(AVAL.join), AVALC.join), object = add_suffix_to_vars(