diff --git a/NEWS.md b/NEWS.md index 308d427250..b5c743994c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -35,6 +35,8 @@ 2. `?.NGRP` now displays the help page as intended, [#4946](https://github.com/Rdatatable/data.table/issues/4649). Thanks to @KyleHaynes for posting the issue, and Cole Miller for the fix. `.NGRP` is a symbol new in v1.13.0; see below in this file. +3. `test.data.table()` failed in non-English locales such as `LC_TIME=fr_FR.UTF-8` due to `Jan` vs `janv.` in tests 168 and 2042, [#3450](https://github.com/Rdatatable/data.table/issues/3450). Thanks to @shrektan for reporting, and @tdhock for making the tests locale-aware. + # data.table [v1.13.0](https://github.com/Rdatatable/data.table/milestone/17?closed=1) (24 Jul 2020) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 058c7db3b2..46b6716cee 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -471,10 +471,13 @@ test(167.3, DT[,plot(b,f),by=.(grp)], data.table(grp=integer())) try(graphics.off(),silent=TRUE) # IDateTime conversion methods that ggplot2 uses (it calls as.data.frame method) -datetimes = c("2011 NOV18 09:29:16", "2011 NOV18 10:42:40", "2011 NOV18 23:47:12", - "2011 NOV19 01:06:01", "2011 NOV19 11:35:34", "2011 NOV19 11:51:09") +# Since %b is e.g. "nov." in LC_TIME=fr_FR.UTF-8 locale, we need to +# have the target/y value in these tests depend on the locale as well, #3450. +NOV = format(strptime("2000-11-01", "%Y-%m-%d"), "%b") +x = c("09:29:16","10:42:40","23:47:12","01:06:01","11:35:34","11:51:09") +datetimes = paste0("2011 ", NOV, c(18,18,18,19,19,19), " ", x) DT = IDateTime(strptime(datetimes,"%Y %b%d %H:%M:%S")) -test(168.1, DT[,as.data.frame(itime)], data.frame(V1=as.ITime(x<-c("09:29:16","10:42:40","23:47:12","01:06:01","11:35:34","11:51:09")))) +test(168.1, DT[,as.data.frame(itime)], data.frame(V1=as.ITime(x))) test(168.2, as.character(DT[,as.POSIXct(itime,tz="UTC")]), paste(Sys.Date(), x)) test(168.3, as.character(DT[,as.POSIXct(idate,tz="UTC")]), c("2011-11-18","2011-11-18","2011-11-18","2011-11-19","2011-11-19","2011-11-19")) @@ -15065,10 +15068,13 @@ test(2041.2, DT[, median(time), by=g], DT[c(2,5),.(g=g, V1=time)]) # 'invalid trim argument' with optimization level 1; #1876 test(2042.1, DT[ , as.character(mean(date)), by=g, verbose=TRUE ], data.table(g=c("a","b"), V1=c("2018-01-04","2018-01-21")), - output=msg<-"GForce is on, left j unchanged.*Old mean optimization is on, left j unchanged") -test(2042.2, DT[ , format(mean(date),"%b-%Y")], "Jan-2018") + output=msg<-"GForce is on, left j unchanged.*Old mean optimization is on, left j unchanged") +# Since %b is e.g. "janv." in LC_TIME=fr_FR.UTF-8 locale, we need to +# have the target/y value in these tests depend on the locale as well, #3450. +Jan.2018 = format(strptime("2018-01-01", "%Y-%m-%d"), "%b-%Y") +test(2042.2, DT[ , format(mean(date),"%b-%Y")], Jan.2018) test(2042.3, DT[ , format(mean(date),"%b-%Y"), by=g, verbose=TRUE ], # just this case generated the error - data.table(g=c("a","b"), V1=c("Jan-2018","Jan-2018")), output=msg) + data.table(g=c("a","b"), V1=c(Jan.2018, Jan.2018)), output=msg) # gforce wrongly applied to external variable; #875 DT = data.table(x=INT(1,1,1,2,2), y=1:5)