Skip to content

Commit fd37731

Browse files
Added tests for #1091, changed global option to prettyprint.char.
1 parent b4b5bba commit fd37731

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

R/data.table.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ format.data.table <- function (x, ..., justify="none") {
163163
else
164164
paste("<",class(x)[1L],">",sep="")
165165
}
166-
char.trunc <- function(x, trunc.char = getOption("datatable.print.pretty.char")) {
166+
# FR #1091 for pretty printing of character
167+
# TODO: maybe instead of doing "this is...", we could do "this ... test"?
168+
char.trunc <- function(x, trunc.char = getOption("datatable.prettyprint.char")) {
167169
trunc.char = max(0L, suppressWarnings(as.integer(trunc.char[1L])), na.rm=TRUE)
168170
if (!is.character(x) || trunc.char <= 0L) return(x)
169171
idx = which(nchar(x) > trunc.char)

R/onLoad.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"datatable.fread.datatable"="TRUE",
4343
"datatable.old.bywithoutby"="FALSE", # temp rollback method for code migration, will be removed in future
4444
"datatable.fread.dec.experiment"="TRUE", # temp. will remove once stable
45-
"datatable.fread.dec.locale"=if (.Platform$OS.type=="unix") "'fr_FR.utf8'" else "'French_France.1252'"
45+
"datatable.fread.dec.locale"=if (.Platform$OS.type=="unix") "'fr_FR.utf8'" else "'French_France.1252'",
46+
"datatable.prettyprint.char" = NULL # FR #1091
4647
)
4748
for (i in setdiff(names(opts),names(options()))) {
4849
eval(parse(text=paste("options(",i,"=",opts[i],")",sep="")))

inst/tests/tests.Rraw

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6333,6 +6333,12 @@ test(1514.5, isReallyReal(x), TRUE)
63336333
x = as.numeric(runif(2))
63346334
test(1514.6, isReallyReal(x), TRUE)
63356335

6336+
# #1091
6337+
old.option = getOption("datatable.prettyprint.char")
6338+
options(datatable.prettyprint.char = 5L)
6339+
DT = data.table(x=1:2, y=c("abcdefghijk", "lmnopqrstuvwxyz"))
6340+
test(1515.1, grep("abcde...", capture.output(print(DT))), 2L)
6341+
63366342
##########################
63376343

63386344

0 commit comments

Comments
 (0)