Skip to content

Commit 5f45a47

Browse files
committed
tests: structure(NULL, *) is now an error
As of R-devel r88075, structure(NULL, ...) signals an error instead of setting attributes on a new list. Test either behaviour depending on the R version and the SVN revision number.
1 parent 2cb0316 commit 5f45a47

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

inst/tests/tests.Rraw

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,8 +2832,10 @@ test(944.1, DT[, foo:=NULL], DT, warning="Tried to assign NULL to column 'foo',
28322832
test(944.2, DT[,a:=1L], data.table(a=1L)) # can now add columns to an empty data.table from v1.12.2
28332833
test(944.3, DT[,aa:=NULL], data.table(a=1L), warning="Tried to assign NULL to column 'aa', but this column does not exist to remove")
28342834
test(944.4, DT[,a:=NULL], data.table(NULL))
2835-
if (base::getRversion() >= "3.4.0") {
2835+
if (base::getRversion() >= "3.4.0" && base::getRversion() < "4.6.0") {
28362836
test(944.5, typeof(structure(NULL, class=c("data.table","data.frame"))), 'list', warning="deprecated, as NULL cannot have attributes") # R warns which is good and we like
2837+
} else if (base::getRversion() >= "4.6.0" && !is.na(Rsvn <- as.numeric(R.version$`svn rev`)) && Rsvn >= 88075) {
2838+
test(944.5, structure(NULL, class=c("data.table","data.frame")), error = "attempt to set an attribute on NULL")
28372839
}
28382840
DT = data.table(a=numeric())
28392841
test(945, DT[,b:=a+1], data.table(a=numeric(),b=numeric()))

0 commit comments

Comments
 (0)