-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
^LICENSE\.md$ | ||
^\.github$ | ||
^vvprojector\.Rproj$ | ||
^\.Rproj\.user$ | ||
^helperfunctions$ | ||
^_pkgdown\.yml$ | ||
^docs$ | ||
^pkgdown$ | ||
^TODO\.md$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(overwrite_dot_arguments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#' Overwrite arguments with dot arguments | ||
#' | ||
#' This function takes a list of function arguments and additional arguments passed | ||
#' with the dot (...). It overwrites the function arguments with the values from the | ||
#' dot arguments if they have the same names. | ||
#' | ||
#' @param function_args A named list of function arguments. | ||
#' @param ... Additional arguments passed with the dot (...). These arguments will | ||
#' overwrite the corresponding ones in \code{function_args} if they have the same names. | ||
#' | ||
#' @return A list containing the original \code{function_args} with any overwritten values | ||
#' from the dot arguments. | ||
#' | ||
#' @examples | ||
#' # Example usage | ||
#' original_args <- list(a = 1, b = 2) | ||
#' result <- overwrite_dot_arguments(original_args, b = 3, c = 4) | ||
#' result | ||
#' | ||
#' @export | ||
overwrite_dot_arguments <- function(function_args, ...) { | ||
dots <- list(...) | ||
return(c(function_args[setdiff(names(function_args), names(dots))], dots)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(vvprojector) | ||
|
||
test_check("vvprojector") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
test_that("overwrite_dot_arguments correctly overwrites arguments", { | ||
# Test case 1: Basic functionality | ||
original_args <- list(a = 1, b = 2) | ||
result <- overwrite_dot_arguments(original_args, b = 3, c = 4) | ||
expect_equal(result$a, 1) | ||
expect_equal(result$b, 3) | ||
expect_equal(result$c, 4) | ||
|
||
# Test case 2: Overwriting with the same value | ||
result <- overwrite_dot_arguments(original_args, b = 2) | ||
expect_equal(result$a, 1) | ||
expect_equal(result$b, 2) | ||
expect_equal(result$c, NULL) | ||
|
||
# Test case 3: No overwriting when no matching names | ||
result <- overwrite_dot_arguments(original_args, d = 5) | ||
expect_equal(result$a, 1) | ||
expect_equal(result$b, 2) | ||
expect_equal(result$d, 5) | ||
}) |