Skip to content

Commit

Permalink
Skip missing argument checks in the .validate_*() functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcol committed Jan 7, 2025
1 parent 02b3860 commit 9113c6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
12 changes: 0 additions & 12 deletions R/internals_RLum.R
Original file line number Diff line number Diff line change
Expand Up @@ -1139,10 +1139,6 @@ SW <- function(expr) {
if (is.null(arg) && null.ok)
return(NULL)

if (missing(choices)) {
.throw_error("'choices' must be provided")
}

## name of the argument to report if not specified
if (is.null(name))
name <- all.vars(match.call())[1]
Expand Down Expand Up @@ -1208,10 +1204,6 @@ SW <- function(expr) {
.validate_class <- function(arg, classes, throw.error = TRUE,
name = NULL, extra = NULL) {

if (missing(classes)) {
.throw_error("'classes' must be provided")
}

## name of the argument to report if not specified
if (is.null(name))
name <- sprintf("'%s'", all.vars(match.call())[1])
Expand Down Expand Up @@ -1303,10 +1295,6 @@ SW <- function(expr) {
.validate_length <- function(arg, exp.length, throw.error = TRUE,
name = NULL) {

if (missing(exp.length)) {
.throw_error("'exp.length' must be provided")
}

## name of the argument to report if not specified
if (is.null(name))
name <- sprintf("'%s'", all.vars(match.call())[1])
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test_internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ test_that("Test internals", {
.validate_args(arg)
}
expect_error(fun.err("val1"),
"[test()] 'choices' must be provided",
fixed = TRUE)
"is missing, with no default")

## .validate_class() ------------------------------------------------------
fun1 <- function(arg) {
Expand All @@ -304,7 +303,7 @@ test_that("Test internals", {
expect_error(fun1(NULL),
"'arg' should be of class 'data.frame'")
expect_error(.validate_class(test <- 1:5),
"'classes' must be provided")
"is missing, with no default")
expect_error(.validate_class(test <- 1:5, "data.frame"),
"'test' should be of class 'data.frame'")
expect_error(.validate_class(test <- 1:5, c("list", "data.frame", "numeric")),
Expand Down Expand Up @@ -350,7 +349,7 @@ test_that("Test internals", {
## .validate_length() -----------------------------------------------------
expect_true(.validate_length(letters, 26))
expect_error(.validate_length(letters),
"'exp.length' must be provided")
"is missing, with no default")
expect_error(.validate_length(letters, 25),
"'letters' should have length 25")
expect_error(.validate_length(letters, 25, name = "'other_name'"),
Expand Down

0 comments on commit 9113c6f

Please sign in to comment.