Skip to content

Commit 571eadc

Browse files
Add test with locally-defined S4 methods as globals [#615]
1 parent 36c8f34 commit 571eadc

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future
2-
Version: 1.25.0-9009
2+
Version: 1.25.0-9010
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Imports:
55
digest,
@@ -10,6 +10,7 @@ Imports:
1010
tools,
1111
utils
1212
Suggests:
13+
methods,
1314
RhpcBLASctl,
1415
R.rsp,
1516
markdown

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: future
22
===============
33

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

66
SIGNIFICANT CHANGES:
77

tests/globals,S4methods.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
source("incl/start.R")
2+
library(methods)
3+
4+
keepWhere <- getOption("future.globals.keepWhere")
5+
6+
message("*** Globals - S4 methods ...")
7+
8+
setGeneric("my_fcn", function(x) {
9+
standardGeneric("my_fcn")
10+
})
11+
12+
setMethod("my_fcn", methods::signature(x = "numeric"), function(x) {
13+
x^2
14+
})
15+
16+
truth <- my_fcn(3)
17+
18+
for (strategy in supportedStrategies()) {
19+
message("Type of future: ", strategy)
20+
plan(strategy)
21+
22+
## FIXME: https://github.com/HenrikBengtsson/future/issues/615
23+
if (strategy %in% c("sequential", "multicore")) {
24+
options(future.globals.keepWhere = TRUE)
25+
}
26+
27+
f <- future({ my_fcn(3) })
28+
v <- value(f)
29+
print(v)
30+
stopifnot(v == truth)
31+
32+
## Make sure to reset option, if changed
33+
options(future.globals.keepWhere = keepWhere)
34+
}
35+
36+
message("*** Globals - S4 methods ... DONE")
37+
38+
source("incl/end.R")

0 commit comments

Comments
 (0)