File: dotdotdot.R

package info (click to toggle)
r-cran-future.batchtools 0.12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 528 kB
  • sloc: sh: 82; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,358 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
source("incl/start.R")
library("listenv")

strategies <- c("batchtools_interactive", "batchtools_local")

## CRAN processing times:
## On Windows 32-bit, don't run these tests
if (!fullTest && isWin32) strategies <- character(0L)


message("*** Global argument '...' in futures ...")

sum_fcns <- list()

sum_fcns$A <- function(x, ...) {
  message("Arguments '...' exists: ", exists("...", inherits = TRUE))
  y %<-% { sum(x, ...) }
  y
}


sum_fcns$B <- function(x, ...) {
  sumt <- function(x) {
    message("Arguments '...' exists: ", exists("...", inherits = TRUE))
    y %<-% { sum(x, ...) }
    y
  }
  sumt(x)
}

sum_fcns$C <- function(x, y) {
  message("Arguments '...' exists: ", exists("...", inherits = TRUE))
  y %<-% { sum(x, y) }
  y
}

sum_fcns$D <- function(x, y) {
  message("Arguments '...' exists: ", exists("...", inherits = TRUE))
  y %<-% { sum(x, y, ...) }
  y
}


for (strategy in strategies) {
  plan(strategy, substitute = FALSE)

  for (name in names(sum_fcns)) {
    mprintf("** Sum function '%s' with plan('%s') ...\n", name, strategy)
    sum_fcn <- sum_fcns[[name]]
    print(sum_fcn)
    y <- try(sum_fcn(1:2, 3))
    print(y)
    if (name %in% c("D")) {
      stopifnot(inherits(y, "try-error"))
    } else {
      stopifnot(y == 6)
    }
  }
}

message("*** Global argument '...' in futures ... DONE")

source("incl/end.R")