diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 03fecf3da6..5c1131240c 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -15403,6 +15403,20 @@ DT = data.table(d=sample(seq(as.Date("2015-01-01"), as.Date("2015-01-05"), by="d test(2070.01, typeof(DT$d), "double") test(2070.02, DT[, .N, keyby=d, verbose=TRUE], output="Column 1.*date.*8 byte double.*no fractions are present.*4 byte integer.*to save space and time") +# coverage along with switch+default pairing +test(2071.01, dcast(data.table(id=1, grp=1, e=expression(1)), id ~ grp, value.var='e'), error="Unsupported column type in fcast val: 'expression'") +test(2071.02, is_na(data.table(expression(1))), error="Unsupported column type 'expression'") +test(2071.03, is_na(data.table(1L), 2L), error="Item 1 of 'cols' is 2 which is outside") +test(2071.04, is_na(list(1L, 1:2)), error="Column 2 of input list x is length 2, inconsistent") +test(2071.05, any_na(data.table(1L), 2L), error="Item 1 of 'cols' is 2 which is outside") +test(2071.06, any_na(list(1L, 1:2)), error="Column 2 of input list x is length 2, inconsistent") +test(2071.07, any_na(data.table(as.raw(0L))), FALSE) +test(2071.08, any_na(data.table(c(1+1i, NA)))) +test(2071.09, any_na(data.table(expression(1))), error="Unsupported column type 'expression'") +test(2071.10, dcast(data.table(a=1, b=1, l=list(list(1))), a ~ b, value.var='l'), + data.table(a=1, `1`=list(list(1)), key='a')) +test(2071.11, dcast(data.table(a = 1, b = 2, c = 3), a ~ b, value.var = 'c', fill = '2'), + data.table(a=1, `2`=3, key='a')) ################################### # Add new tests above this line # diff --git a/src/assign.c b/src/assign.c index d7f5d45785..01a6147ec4 100644 --- a/src/assign.c +++ b/src/assign.c @@ -1021,8 +1021,8 @@ void writeNA(SEXP v, const int from, const int n) // If there's ever a way added to R API to pass NA_STRING to allocVector() to tell it to initialize with NA not "", would be great for (int i=from; i<=to; ++i) SET_STRING_ELT(v, i, NA_STRING); break; - case VECSXP : - // list columns already have each item initialized to NULL + case VECSXP : case EXPRSXP : + // list & expression columns already have each item initialized to NULL break; default : error("Internal error: writeNA passed a vector of type '%s'", type2char(TYPEOF(v))); // # nocov diff --git a/src/bmerge.c b/src/bmerge.c index ec003ff547..a7246786a8 100644 --- a/src/bmerge.c +++ b/src/bmerge.c @@ -265,10 +265,11 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg } if (col>-1 && op[col] != EQ) { switch (op[col]) { - case LE : xlow = xlowIn; break; - case LT : xupp = xlow + 1; xlow = xlowIn; break; - case GE : if (ival.i != NA_INTEGER) xupp = xuppIn; break; - case GT : xlow = xupp - 1; if (ival.i != NA_INTEGER) xupp = xuppIn; break; + case LE : xlow = xlowIn; break; + case LT : xupp = xlow + 1; xlow = xlowIn; break; + case GE : if (ival.i != NA_INTEGER) xupp = xuppIn; break; + case GT : xlow = xupp - 1; if (ival.i != NA_INTEGER) xupp = xuppIn; break; + default : error("Internal error in bmerge_r for '%s' column. Unrecognized value op[col]=%d", type2char(TYPEOF(xc)), op[col]); // #nocov } // for LE/LT cases, we need to ensure xlow excludes NA indices, != EQ is checked above already if (op[col] <= 3 && xlow