Skip to content

Commit

Permalink
Add unit tests for Rdatatable#4981
Browse files Browse the repository at this point in the history
  • Loading branch information
OfekShilon committed May 9, 2021
1 parent f2d037f commit df74b8a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -17410,3 +17410,14 @@ x = data.table(id = 1:4, key = 'id')
y = data.table(id = 2:5, key = 'id')
z = data.table(c=c(2L, 2L, 1L, 1L), id=c(2L, 4L, 3L, NA))
test(2178, x[y, .SD, by=.(c(2L, 1L, 2L, 1L))], z)

# `keyby` allows mixing eval/get with direct columns, #4981
dt <- data.table(a=c(1,2), b=c(3,4), c=c(1,0))
dt2 <- dt[,.(suma=sum(a)), keyby=.(b=get("b"),c)]
test(2179.1, dt2[1, suma], 1)
dt2 <- dt[2,.(suma=sum(a)), keyby=.(b=b,c)]
test(2179.2, dt2[1, suma], 2)
dt2 <- dt[2,.(suma=sum(a)), keyby=.(b=get("b"))]
test(2179.3, dt2[1, suma], 2)
dt2 <- dt[2,.(suma=sum(a)), keyby=.(b=get("b"),c)]
test(2179.4, dt2[1, suma], 2)

0 comments on commit df74b8a

Please sign in to comment.