Skip to content

Commit

Permalink
par_convert_f test edited
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmafelix committed Feb 27, 2025
1 parent cc7abbe commit 2cac908
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions R/scale_process.R
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ par_multirasters <-
#'
#' @examples
#' # Define an original function that expects arguments 'group' and 'score'
#' original_fun <- function(group, score) {
#' list(group = group, score = score)
#' original_fun <- function(group, score, home = FALSE) {
#' list(group = group, score = score, home = home)
#' }
#'
#' # Create a new function that maps 'x' to 'group' and 'y' to 'score'
Expand Down
4 changes: 2 additions & 2 deletions man/par_convert_f.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions tests/testthat/test-scale_process.R
Original file line number Diff line number Diff line change
Expand Up @@ -1345,20 +1345,21 @@ testthat::test_that(

# par_map_args tests ####
testthat::test_that("par_convert_f works", {
example_fun <- function(x, y, z = 1) {
return(c(x = x, y = y, z = z))
example_fun <- function(a, b, z = 1) {
return(c(a = a, b = b, z = z))
}

# Example usage of map_args_xy
testthat::expect_no_error(
resultfoo <-
par_convert_f(
fun = example_fun,
arg_map = c(a = "x", b = "y")
x = a, y = b
)
)

testthat::expect_true(is.function(resultfoo))
result <- resultfoo(a = 10, b = 20, z = 5)
result <- resultfoo(x = 10, y = 20, z = 5)
testthat::expect_true(is.vector(result))
testthat::expect_true(all(names(result) %in% c("a", "b", "z")))
})

0 comments on commit 2cac908

Please sign in to comment.