Skip to content

Commit e22e659

Browse files
authored
Make tests 168,2043 work for any LC_TIME (#4719)
1 parent 172ad69 commit e22e659

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
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.
3737

38+
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.
39+
3840

3941
# data.table [v1.13.0](https://github.com/Rdatatable/data.table/milestone/17?closed=1) (24 Jul 2020)
4042

inst/tests/tests.Rraw

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,13 @@ test(167.3, DT[,plot(b,f),by=.(grp)], data.table(grp=integer()))
471471
try(graphics.off(),silent=TRUE)
472472

473473
# IDateTime conversion methods that ggplot2 uses (it calls as.data.frame method)
474-
datetimes = c("2011 NOV18 09:29:16", "2011 NOV18 10:42:40", "2011 NOV18 23:47:12",
475-
"2011 NOV19 01:06:01", "2011 NOV19 11:35:34", "2011 NOV19 11:51:09")
474+
# Since %b is e.g. "nov." in LC_TIME=fr_FR.UTF-8 locale, we need to
475+
# have the target/y value in these tests depend on the locale as well, #3450.
476+
NOV = format(strptime("2000-11-01", "%Y-%m-%d"), "%b")
477+
x = c("09:29:16","10:42:40","23:47:12","01:06:01","11:35:34","11:51:09")
478+
datetimes = paste0("2011 ", NOV, c(18,18,18,19,19,19), " ", x)
476479
DT = IDateTime(strptime(datetimes,"%Y %b%d %H:%M:%S"))
477-
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"))))
480+
test(168.1, DT[,as.data.frame(itime)], data.frame(V1=as.ITime(x)))
478481
test(168.2, as.character(DT[,as.POSIXct(itime,tz="UTC")]), paste(Sys.Date(), x))
479482
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"))
480483

@@ -15065,10 +15068,13 @@ test(2041.2, DT[, median(time), by=g], DT[c(2,5),.(g=g, V1=time)])
1506515068
# 'invalid trim argument' with optimization level 1; #1876
1506615069
test(2042.1, DT[ , as.character(mean(date)), by=g, verbose=TRUE ],
1506715070
data.table(g=c("a","b"), V1=c("2018-01-04","2018-01-21")),
15068-
output=msg<-"GForce is on, left j unchanged.*Old mean optimization is on, left j unchanged")
15069-
test(2042.2, DT[ , format(mean(date),"%b-%Y")], "Jan-2018")
15071+
output=msg<-"GForce is on, left j unchanged.*Old mean optimization is on, left j unchanged")
15072+
# Since %b is e.g. "janv." in LC_TIME=fr_FR.UTF-8 locale, we need to
15073+
# have the target/y value in these tests depend on the locale as well, #3450.
15074+
Jan.2018 = format(strptime("2018-01-01", "%Y-%m-%d"), "%b-%Y")
15075+
test(2042.2, DT[ , format(mean(date),"%b-%Y")], Jan.2018)
1507015076
test(2042.3, DT[ , format(mean(date),"%b-%Y"), by=g, verbose=TRUE ], # just this case generated the error
15071-
data.table(g=c("a","b"), V1=c("Jan-2018","Jan-2018")), output=msg)
15077+
data.table(g=c("a","b"), V1=c(Jan.2018, Jan.2018)), output=msg)
1507215078

1507315079
# gforce wrongly applied to external variable; #875
1507415080
DT = data.table(x=INT(1,1,1,2,2), y=1:5)

0 commit comments

Comments
 (0)