Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-schwen committed Nov 14, 2023
1 parent 67be016 commit 96e6edc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -18103,3 +18103,7 @@ test(2239.1, null.data.table()[, a := x], dt1)
test(2239.2, set(null.data.table(), j="a", value=x), dt1)
test(2239.3, null.data.table()[, c("a","b") := x], dt2)
test(2239.4, set(null.data.table(), j=c("a","b"), value=x), dt2)
test(2239.5, null.data.table()[, c("a","b") := list(1:2, 3:4)], data.table(a=1:2, b=3:4))
test(2239.6, set(null.data.table(), j=c("a","b"), value=list(1:2, 3:4)), data.table(a=1:2, b=3:4))
test(2239.7, data.table(a=1, b=2)[, c("a", "b") := list(NULL, NULL)], null.data.table())
test(2239.8, data.table(a=1, b=2)[, c("a", "b") := list(NULL)], null.data.table())
2 changes: 1 addition & 1 deletion src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
// Not possible to test because R won't permit attributes be attached to NULL (which is good and we like); warning from R 3.4.0+ tested by 944.5
}
const int nrow = LENGTH(dt) ? length(VECTOR_ELT(dt,0)) :
(isNewList(values) && length(values) && (length(values)==length(cols)) ? length(VECTOR_ELT(values,0)) : length(values));
(isNewList(values) && length(values) && (length(values)==length(newcolnames)) ? length(VECTOR_ELT(values,0)) : length(values));
// ^ when null data.table the new nrow becomes the fist column added
// #5738 ^ distinguish between adding list column or multiple columns at once
if (isNull(rows)) {
Expand Down

0 comments on commit 96e6edc

Please sign in to comment.