Skip to content

Commit

Permalink
Merge pull request #237 from epiforecasts/fix-deparse
Browse files Browse the repository at this point in the history
use deparse instead of deparse1
  • Loading branch information
nikosbosse authored Jun 1, 2022
2 parents ec05742 + 6f6e815 commit f356634
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/input-check-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ check_not_null <- function(...) {
vars <- list(...)
varnames <- names(vars)

calling_function <- deparse1(sys.calls()[[sys.nframe() - 1]])
calling_function <- deparse(sys.calls()[[sys.nframe() - 1]])

for (i in seq_along(vars)) {
varname <- varnames[i]
Expand Down Expand Up @@ -165,7 +165,7 @@ check_equal_length <- function(...,
}

if (length(unique(lengths)) != 1) {
calling_function <- deparse1(sys.calls()[[sys.nframe() - 1]])
calling_function <- deparse(sys.calls()[[sys.nframe() - 1]])
stop(paste0(
"Arguments passed to the following function call: '",
calling_function,
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-input-check-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ test_that("Check equal length works if all arguments have length 1", {
)
expect_equal(out, 0.05)
})


test_that("Check_not_null works", {
test_function <- function(argument = NULL) {
scoringutils:::check_not_null("argument" = argument)
return(paste("Input:", argument))
}
out <- test_function("works")
expect_equal(out, "Input: works")
expect_error(test_function())
})

0 comments on commit f356634

Please sign in to comment.