| 1 |
message("isForkedNode() ...") |
| 2 |
|
| 3 |
# 1. Test with a default object |
| 4 |
x <- 123 |
| 5 |
res <- isForkedNode(x) |
| 6 |
stopifnot(is.na(res)) |
| 7 |
|
| 8 |
x <- list(a = 1, b = 2) |
| 9 |
res <- isForkedNode(x) |
| 10 |
stopifnot(is.na(res)) |
| 11 |
|
| 12 |
|
| 13 |
# 2. Test with a forknode object |
| 14 |
## Create a dummy forknode object |
| 15 |
## It's enough to set its class attribute |
| 16 |
node <- structure(list(), class = "forknode") |
| 17 |
res <- isForkedNode(node) |
| 18 |
stopifnot(res) |
| 19 |
|
| 20 |
|
| 21 |
# 3. Test with a cluster object |
| 22 |
## Create dummy cluster objects |
| 23 |
node1 <- structure(list(), class = "forknode") |
| 24 |
node2 <- structure(list(), class = "notforknode") ## A dummy node that is not a forknode |
| 25 |
node3 <- structure(list(), class = "forknode") |
| 26 |
|
| 27 |
cluster_obj <- list(node1, node2, node3) |
| 28 |
class(cluster_obj) <- "cluster" |
| 29 |
|
| 30 |
res <- isForkedNode(cluster_obj) |
| 31 |
stopifnot(is.logical(res), length(res) == 3) |
| 32 |
stopifnot(res[1]) |
| 33 |
stopifnot(is.na(res[2])) |
| 34 |
stopifnot(res[3]) |
| 35 |
|
| 36 |
message("isForkedNode() ... done") |