tests/transparent.R

source("incl/start.R")
library("listenv")

message("*** transparent() ...")

## No global variables
f <- try(transparent({
  42L
}), silent = FALSE)
print(f)
stopifnot(inherits(f, "SequentialFuture"), !f$lazy)

print(resolved(f))
y <- value(f)
print(y)
stopifnot(y == 42L)


plan(transparent)
## No global variables
f <- try(future({
  42L
}), silent = FALSE)
print(f)
stopifnot(inherits(f, "SequentialFuture"), !f$lazy)

print(resolved(f))
y <- value(f)
print(y)
stopifnot(y == 42L)


## A global variable
a <- 0
f <- try(future({
  b <- 3
  c <- 2
  a * b * c
}))
print(f)

message("*** transparent() ... DONE")

source("incl/end.R")
MINATILO/FUTURE documentation built on Dec. 17, 2021, 1:21 a.m.