Skip to content

Commit 6afd693

Browse files
move setDT behavior test into tests.Rraw
1 parent fdbff9b commit 6afd693

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

inst/tests/mergelist.Rraw

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ test(12.16, cbindlist(list(data.table(a=integer()), data.table(b=1:2)), copy=FAL
5353
test(12.17, cbindlist(list(data.table(a=1L), data.table(b=1:2)), copy=FALSE), error="have to have the same number of rows")
5454

5555
## retain indices
56-
local({
57-
d = data.table(x=1:2, y=2:1, z=2:1, v1=1:2) ## ensure setDT will retain key and indices when it is called on the list, bc Ccbindlist returns list
58-
setkeyv(d, "x"); setindexv(d, list("y", "z"))
59-
a = attributes(d)
60-
attributes(d) = a[!names(a) %in% c("class", ".internal.selfref", "row.names")]
61-
test(13.01, class(d), "list")
62-
setDT(d)
63-
test(13.02, key(d), "x")
64-
# test(13.03, hasindex(d, "y") && hasindex(d, "z"))
65-
})
6656
local({
6757
l = list(
6858
data.table(id1=1:5, id2=5:1, id3=1:5, v1=1:5),

inst/tests/tests.Rraw

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21252,3 +21252,15 @@ it <- as.ITime('00:00:00')
2125221252
test(2323.1, names(data.frame(COL = it)), "COL")
2125321253
test(2323.2, names(data.frame(b = 1, COL = it)), c("b", "COL"))
2125421254
test(2323.3, names(as.data.frame(it, optional=TRUE)), NULL)
21255+
21256+
## ensure setDT will retain key and indices when it is called on the list (cbindlist assumes this)
21257+
local({
21258+
d = data.table(x=1:2, y=2:1, z=2:1, v1=1:2)
21259+
setkeyv(d, "x"); setindexv(d, list("y", "z"))
21260+
a = attributes(d)
21261+
attributes(d) = a[!names(a) %in% c("class", ".internal.selfref", "row.names")]
21262+
test(2324.01, class(d), "list")
21263+
setDT(d)
21264+
test(2324.02, key(d), "x")
21265+
test(2324.03, hasindex(d, "y") && hasindex(d, "z"))
21266+
})

0 commit comments

Comments
 (0)