Skip to content

Commit

Permalink
check for mirai_map() function early; upgrade minitest
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Oct 3, 2024
1 parent 5efaa55 commit a7577e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions R/map.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
#'
mirai_map <- function(.x, .f, ..., .args = list(), .promise = NULL, .compute = "default") {

is.function(.f) || stop(sprintf(._[["function_required"]], typeof(.f)))
envir <- ..[[.compute]]
is.null(envir) && {
.x
Expand Down
1 change: 1 addition & 0 deletions R/mirai-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
daemons_unset = "daemons must be set to use launchers",
dispatcher_args = "'dispatcher' must be one of 'process', 'thread' or 'none'",
dot_required = "remote_config(): '.' must be an element of the character vector(s) supplied to 'args'",
function_required = "'.f' must be of type function, not %s",
missing_expression = "missing expression, perhaps wrap in {}?",
missing_url = "at least one URL must be supplied for 'url' or 'n' must be at least 1",
named_args = "all items in '.args' must be named, unless supplying an environment",
Expand Down
5 changes: 3 additions & 2 deletions tests/tests.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# minitest - a minimal testing framework v0.0.1 --------------------------------
# minitest - a minimal testing framework v0.0.2 --------------------------------
test_library <- function(package) library(package = package, character.only = TRUE)
test_true <- function(x) invisible(isTRUE(x) || {print(x); stop("the above was returned instead of TRUE")})
test_null <- function(x) invisible(is.null(x) || {print(x); stop("the above was returned instead of NULL")})
Expand All @@ -8,7 +8,7 @@ test_class <- function(class, x) invisible(inherits(x, class) || {stop("object o
test_equal <- function(a, b) invisible(a == b || {print(a); print(b); stop("the above expressions were not equal")})
test_identical <- function(a, b) invisible(identical(a, b) || {print(a); print(b); stop("the above expressions were not identical")})
test_print <- function(x) invisible(is.character(capture.output(print(x))) || stop("print output of expression cannot be captured as a character value"))
test_error <- function(x, containing = "") invisible(inherits(x <- tryCatch(x, error = identity), "error") && grepl(containing, x[["message"]], fixed = TRUE) || stop("expected error message containing '", containing, "' was not generated"))
test_error <- function(x, containing = "") invisible(inherits(x <- tryCatch(x, error = identity), "error") && grepl(containing, x[["message"]], fixed = TRUE) || stop("Expected error message containing: ", containing, "\nActual error message: ", x[["message"]]))
# ------------------------------------------------------------------------------

test_library("mirai")
Expand All @@ -21,6 +21,7 @@ test_zero(daemons(0L))
test_error(mirai(), "missing expression, perhaps wrap in {}?")
test_error(mirai(a, 1), "all '...' arguments must be named")
test_error(mirai(a, .args = list(1)), "all items in '.args' must be named")
test_error(mirai_map(1:2, "a function"), "must be of type function, not character")
test_error(daemons(url = "URL"), "Invalid argument")
test_error(daemons(-1), "zero or greater")
test_error(daemons(n = 0, url = "ws://localhost:0"), "1 or greater")
Expand Down

0 comments on commit a7577e5

Please sign in to comment.