Skip to content

Commit bb830f8

Browse files
committed
updaed testst
1 parent 1ae5f7d commit bb830f8

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

inst/tests/tests.Rraw

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21429,24 +21429,28 @@ test(2330.8, as.data.table(list(M), keep.rownames=TRUE), data.table(rn=rep("", 3
2142921429

2143021430
#2606 Recursive tables() naming convention
2143121431
test(2331.1, local({
21432-
dt1 <- data.table(a = 1)
21433-
lst <- list(inner = dt1)
21434-
"lst$inner" %in% tables(recursive = TRUE)$NAME
21432+
lst_named = list(inner = data.table(a = 1))
21433+
lst_unnamed = list(data.table(b = 2))
21434+
nested = list(l1 = list(l2 = data.table(c = 3)))
21435+
out = tables(recursive = TRUE)$NAME
21436+
all(c("lst_named$inner", "lst_unnamed[[1]]", "nested$l1$l2") %in% out)
2143521437
}))
2143621438
test(2331.2, local({
21437-
lst <- list(data.table(b = 2))
21438-
"lst[[1]]" %in% tables(recursive = TRUE)$NAME
21439+
mixed = list(data.table(x = 1), y = data.table(z = 2))
21440+
out = tables(recursive = TRUE)$NAME
21441+
all(c("mixed[[1]]", "mixed$y") %in% out)
2143921442
}))
2144021443
test(2331.3, local({
21441-
nested <- list(l1 = list(l2 = data.table(c = 3)))
21442-
"nested$l1$l2" %in% tables(recursive = TRUE)$NAME
21444+
mixed_nested = list(
21445+
A = list(data.table(p = 1), q = data.table(q = 2)))
21446+
out = tables(recursive = TRUE)$NAME
21447+
all(c("mixed_nested$A[[1]]", "mixed_nested$A$q") %in% out)
2144321448
}))
2144421449
test(2331.4, local({
21445-
cycle <- list()
21446-
cycle[[1]] <- cycle
21447-
cycle[[2]] <- list(cycle) # deeper nesting to increase chance of second encounter
21448-
cycle[[3]] <- data.table(x = 1)
21449-
res <- tables(recursive = TRUE)$NAME
21450-
"cycle[[3]]" %in% res && all(!grepl("cycle\\[\\[1\\]\\]", res)) && all(!grepl("cycle\\[\\[2\\]", res))
21450+
dt <- data.table(val = 42)
21451+
e <- new.env()
21452+
e$dt <- dt
21453+
e$self <- e
21454+
out = tables(recursive = TRUE, env = e)$NAME
21455+
identical(out, "dt")
2145121456
}))
21452-

0 commit comments

Comments
 (0)