Skip to content

Commit

Permalink
Merge pull request #337 from Roche-GSK/298_bug_is_date
Browse files Browse the repository at this point in the history
Updated failure message
  • Loading branch information
Thomas Neitmann authored Jul 13, 2021
2 parents 88a637c + 132229d commit b8ed299
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,20 @@ is_date <- function(arg) {
is.instant(arg)
}
on_failure(is_date) <- function(call, env) {
evld <- eval(call$arg, envir = env)
len <- length(evld)
msg <- if (len == 0) {
deparse(evld)
} else if (len == 1) {
evld
} else {
paste0("c(", paste(head(evld, 5), collapse = ", "), `if`(len > 5, ", ..."), ")")
}
paste0(
"Argument ",
deparse(call$arg),
" = ",
eval(call$arg, envir = env),
msg,
" is not a lubridate date."
)
}
Expand Down

0 comments on commit b8ed299

Please sign in to comment.