Skip to content

Commit

Permalink
Add test with locally-defined S4 methods as globals [#615]
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed May 6, 2022
1 parent 36c8f34 commit 571eadc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: future
Version: 1.25.0-9009
Version: 1.25.0-9010
Title: Unified Parallel and Distributed Processing in R for Everyone
Imports:
digest,
Expand All @@ -10,6 +10,7 @@ Imports:
tools,
utils
Suggests:
methods,
RhpcBLASctl,
R.rsp,
markdown
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: future
===============

Version: 1.25.0-9009 [2022-05-03]
Version: 1.25.0-9010 [2022-05-06]

SIGNIFICANT CHANGES:

Expand Down
38 changes: 38 additions & 0 deletions tests/globals,S4methods.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
source("incl/start.R")
library(methods)

keepWhere <- getOption("future.globals.keepWhere")

message("*** Globals - S4 methods ...")

setGeneric("my_fcn", function(x) {
standardGeneric("my_fcn")
})

setMethod("my_fcn", methods::signature(x = "numeric"), function(x) {
x^2
})

truth <- my_fcn(3)

for (strategy in supportedStrategies()) {
message("Type of future: ", strategy)
plan(strategy)

## FIXME: https://github.com/HenrikBengtsson/future/issues/615
if (strategy %in% c("sequential", "multicore")) {
options(future.globals.keepWhere = TRUE)
}

f <- future({ my_fcn(3) })
v <- value(f)
print(v)
stopifnot(v == truth)

## Make sure to reset option, if changed
options(future.globals.keepWhere = keepWhere)
}

message("*** Globals - S4 methods ... DONE")

source("incl/end.R")

0 comments on commit 571eadc

Please sign in to comment.