Skip to content

Commit 5b50b6f

Browse files
TESTS: Add tests for registerDoFuture(flavor = '%dofuture%')
1 parent e85c9aa commit 5b50b6f

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: doFuture
2-
Version: 1.0.2-9004
2+
Version: 1.0.2-9005
33
Title: Use Foreach to Parallelize via the Future Framework
44
Depends:
55
foreach (>= 1.5.0),
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
library(doFuture)
2+
3+
options(future.debug = FALSE)
4+
5+
message("*** registerDoFuture(flavor = '%dofuture%') ...")
6+
7+
registerDoFuture(flavor = "%dofuture%")
8+
9+
plan(multisession, workers = 2L)
10+
11+
a <- 3.14
12+
b <- 2
13+
y_truth <- foreach(1:2, .export = c("a", "b")) %do% { b * a }
14+
str(y_truth)
15+
16+
17+
y1 <- foreach(1:2, .export = c("a", "b")) %dopar% { b * a }
18+
str(y1)
19+
stopifnot(identical(y1, y_truth))
20+
21+
y2 <- foreach(1:2) %dopar% { b * a }
22+
str(y2)
23+
stopifnot(identical(y2, y_truth))
24+
25+
y3 <- foreach(1:2, .export = NULL) %dopar% { b * a }
26+
str(y3)
27+
stopifnot(identical(y3, y_truth))
28+
29+
y4 <- foreach(1:2, .export = "a") %dopar% { b * a }
30+
str(y4)
31+
stopifnot(identical(y4, y_truth))
32+
33+
y5 <- foreach(1:2, .export = "c", .noexport = "d", .packages = "stats") %dopar% { b * a }
34+
str(y5)
35+
stopifnot(identical(y5, y_truth))
36+
37+
38+
# Shutdown current plan
39+
plan(sequential)
40+
41+
message("*** registerDoFuture(flavor = '%dofuture%') ... DONE")
42+

0 commit comments

Comments
 (0)