Skip to content

Commit 1d29473

Browse files
committed
added tests
1 parent 49c52d0 commit 1d29473

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

R/data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ replace_dot_alias = function(e) {
14101410
if (is.function(jval)) {
14111411
stopf("RHS of `:=` is a function. To create a new column of functions, it must be a list column (e.g., wrap in `list()`).")
14121412
} else if (is.list(jval) && length(jval) == 1 && is.function(jval[[1L]])) {
1413-
stopf("RHS of `:=` is a length-1 list containing a function. `data.table` does not automatically recycle lists. To create a list-column, use `rep(list(myfun), .N)` or `list(replicate(.N, myfun))` to match the number of rows.")
1413+
stopf("RHS of `:=` is a length-1 list containing a function. `data.table` does not automatically recycle lists. To create a list-column, use `rep(list(myfun), .N)` to match the number of rows.")
14141414
}
14151415
}
14161416
# TODO?: use set() here now that it can add new columns. Then remove newnames and alloc logic above.

inst/tests/tests.Rraw

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21157,3 +21157,8 @@ test(2317.6, DT1[DF1, on='a', .(d = x.a + i.d)]$d, 5)
2115721157
test(2317.7, DT1[DF2, on='a', e := i.e]$e, 5)
2115821158
test(2317.8, DT1[DF2, on='a', e2 := x.a + i.e]$e2, 6)
2115921159
test(2317.9, DT1[DF2, on='a', .(e = x.a + i.e)]$e, 6)
21160+
21161+
DT = data.table(x = 1:3)
21162+
21163+
test(2318.1, DT[, y := mean], error = "RHS of `:=` is a function")
21164+
test(2318.2, DT[, y := list(mean)], error = "RHS of `:=` is a length-1 list containing a function")

0 commit comments

Comments
 (0)